diff --git a/src/preprocess.ts b/src/preprocess.ts index 98bd9a81..6bf91d47 100644 --- a/src/preprocess.ts +++ b/src/preprocess.ts @@ -27,8 +27,7 @@ export function preprocess(context: BuildContext) { function preprocessWorker(context: BuildContext) { const bundlePromise = bundleCoreComponents(context); const deepLinksPromise = getBooleanPropertyValue(Constants.ENV_PARSE_DEEPLINKS) ? deepLinking(context) : Promise.resolve(); - const componentSassPromise = lookUpDefaultIonicComponentPaths(context); - return Promise.all([bundlePromise, deepLinksPromise, componentSassPromise]) + return Promise.all([bundlePromise, deepLinksPromise]) .then(() => { if (context.optimizeJs) { return optimization(context, null); @@ -68,15 +67,3 @@ export function preprocessUpdate(changedFiles: ChangedFile[], context: BuildCont return Promise.all(promises); } - -export function lookUpDefaultIonicComponentPaths(context: BuildContext) { - const componentsDirGlob = join(getStringPropertyValue(Constants.ENV_VAR_IONIC_ANGULAR_DIR), 'components', '**', '*.scss'); - const srcDirGlob = join(getStringPropertyValue(Constants.ENV_VAR_SRC_DIR), '**', '*.scss'); - return globAll([componentsDirGlob, srcDirGlob]).then((results: GlobResult[]) => { - const componentPathSet = new Set(); - results.forEach(result => { - componentPathSet.add(result.absolutePath); - }); - context.moduleFiles = Array.from(componentPathSet); - }); -} diff --git a/src/rollup.ts b/src/rollup.ts index 650fb9df..006408ee 100644 --- a/src/rollup.ts +++ b/src/rollup.ts @@ -73,6 +73,17 @@ export function rollupWorker(context: BuildContext, configFile: string): Promise Logger.debug(`bundle.modules: ${bundle.modules.length}`); + // set the module files used in this bundle + // this reference can be used elsewhere in the build (sass) + context.moduleFiles = bundle.modules.map((m) => { + // sometimes, Rollup appends weird prefixes to the path like commonjs:proxy + const index = m.id.indexOf(sep); + if (index >= 0) { + return m.id.substring(index); + } + return m.id; + }); + // cache our bundle for later use if (context.isWatch) { cachedBundle = bundle; @@ -214,4 +225,4 @@ export interface RollupLocationInfo { file: string; line: number; column: number; -} \ No newline at end of file +} diff --git a/src/webpack.ts b/src/webpack.ts index fdc7a765..ea33b970 100644 --- a/src/webpack.ts +++ b/src/webpack.ts @@ -93,6 +93,23 @@ function webpackBuildComplete(stats: any, context: BuildContext, webpackConfig: Logger.debug('Webpack Dependency Map End'); } + // set the module files used in this bundle + // this reference can be used elsewhere in the build (sass) + if (!context.isProd || !context.optimizeJs) { + const files: string[] = stats.compilation.modules.map((webpackObj: any) => { + if (webpackObj.resource) { + return webpackObj.resource; + } else { + return webpackObj.context; + } + }).filter((path: string) => { + // just make sure the path is not null + return path && path.length > 0; + }); + + context.moduleFiles = files; + } + return setBundledFiles(context); } @@ -227,4 +244,4 @@ export interface WebpackOutputObject { export interface WebpackResolveObject { extensions: string[]; modules: string[]; -} \ No newline at end of file +}