Ionic-app-scripts: [0.0.43] Android/Rollup production build output is missing custom CSS

Created on 11 Nov 2016  路  8Comments  路  Source: ionic-team/ionic-app-scripts

Short description of the problem:

When I build my app using ionic run android using Rollup as the bundler, the app's custom CSS is missing and everything looks bad.

I am currently seeing this issue on Windows 10, so that may be relevant. I have attempted to replicate this on iOS with my Mac, but that seems to work fine. I have not tried Webpack on either system. I have tested this on @ionic/[email protected] and everything works correctly.

What behavior are you expecting?

The app's custom CSS should be included in the Android package.

Steps to reproduce:

  1. Create a new project (ionic start test --v2 --ts)
  2. Change the bundler to Rollup.
  3. Install @ionic/app-scripts/@0.0.43
  4. Edit one of the page stylesheets with something obvious. For my test, I added the following to src/pages/home/home.scss:
page-home {
    .content-ios,
    .content-md {
        background-color: red;
    }
}
  1. Run the app on an android device (ionic run android). For my example, the background of the home page should be red, but it will be white instead.
insert any relevant code between the above and below backticks

Which @ionic/app-scripts version are you using?
0.0.43

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

Most helpful comment

It's caused by bundle.modules of rollup, the path on Windows is something like \rootpath\path\ but not D:\rootpath\path.
So the finding in replace logic will not work. ( https://github.com/driftyco/ionic-app-scripts/blob/master/src/sass.ts#L163 )
Wish this info will help you guys to fix this bug.

All 8 comments

Ever since they moved to 0.4+ i am also having problems with roll-up.

Same problem. with both 0.0.43 & 0.0.44
ionic-app-scripts build --bundler webpack will output the right css.

i am having the same issue with 0.0.46 and rollup, with webpack works fine

It's caused by bundle.modules of rollup, the path on Windows is something like \rootpath\path\ but not D:\rootpath\path.
So the finding in replace logic will not work. ( https://github.com/driftyco/ionic-app-scripts/blob/master/src/sass.ts#L163 )
Wish this info will help you guys to fix this bug.

Our temporary solution was adding the following line to sass.ts:

function addComponentSassFiles(componentPath: string, collectedSassFiles: string[], context: BuildContext, sassConfig: SassConfig) {
  let siblingFiles = getSiblingSassFiles(componentPath, sassConfig);

  if (!siblingFiles.length && componentPath.indexOf(sep + 'node_modules') === -1) {

    // if we didn't find anything, see if this module is mapped to another directory
    for (const k in sassConfig.directoryMaps) {
      if (sassConfig.directoryMaps.hasOwnProperty(k)) {
        var actualDirectory = replacePathVars(context, k);
        var mappedDirectory = replacePathVars(context, sassConfig.directoryMaps[k]);

        componentPath = path_1.resolve(componentPath); //Line added
        componentPath = componentPath.replace(actualDirectory, mappedDirectory);

        siblingFiles = getSiblingSassFiles(componentPath, sassConfig);
        if (siblingFiles.length) {
          break;
        }
      }
    }
  }

This is just happening on windows, on Mac env is working properly.

This is working now with latest version (0.0.47)

https://github.com/driftyco/ionic-app-scripts/releases/tag/v0.0.47

This should be resolved in 1.0.0. Please let me know if it's not.

Thanks,
Dan

Was this page helpful?
0 / 5 - 0 ratings