Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit 0554201

Browse files
committed
fix(sass): use webpack/rollup modules for non-optimized build, use optimization data for prod/optimized buids
1 parent 7961095 commit 0554201

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

src/preprocess.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ export function preprocess(context: BuildContext) {
2727
function preprocessWorker(context: BuildContext) {
2828
const bundlePromise = bundleCoreComponents(context);
2929
const deepLinksPromise = getBooleanPropertyValue(Constants.ENV_PARSE_DEEPLINKS) ? deepLinking(context) : Promise.resolve();
30-
const componentSassPromise = lookUpDefaultIonicComponentPaths(context);
31-
return Promise.all([bundlePromise, deepLinksPromise, componentSassPromise])
30+
return Promise.all([bundlePromise, deepLinksPromise])
3231
.then(() => {
3332
if (context.optimizeJs) {
3433
return optimization(context, null);
@@ -68,15 +67,3 @@ export function preprocessUpdate(changedFiles: ChangedFile[], context: BuildCont
6867

6968
return Promise.all(promises);
7069
}
71-
72-
export function lookUpDefaultIonicComponentPaths(context: BuildContext) {
73-
const componentsDirGlob = join(getStringPropertyValue(Constants.ENV_VAR_IONIC_ANGULAR_DIR), 'components', '**', '*.scss');
74-
const srcDirGlob = join(getStringPropertyValue(Constants.ENV_VAR_SRC_DIR), '**', '*.scss');
75-
return globAll([componentsDirGlob, srcDirGlob]).then((results: GlobResult[]) => {
76-
const componentPathSet = new Set<string>();
77-
results.forEach(result => {
78-
componentPathSet.add(result.absolutePath);
79-
});
80-
context.moduleFiles = Array.from(componentPathSet);
81-
});
82-
}

src/rollup.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ export function rollupWorker(context: BuildContext, configFile: string): Promise
7373

7474
Logger.debug(`bundle.modules: ${bundle.modules.length}`);
7575

76+
// set the module files used in this bundle
77+
// this reference can be used elsewhere in the build (sass)
78+
context.moduleFiles = bundle.modules.map((m) => {
79+
// sometimes, Rollup appends weird prefixes to the path like commonjs:proxy
80+
const index = m.id.indexOf(sep);
81+
if (index >= 0) {
82+
return m.id.substring(index);
83+
}
84+
return m.id;
85+
});
86+
7687
// cache our bundle for later use
7788
if (context.isWatch) {
7889
cachedBundle = bundle;
@@ -214,4 +225,4 @@ export interface RollupLocationInfo {
214225
file: string;
215226
line: number;
216227
column: number;
217-
}
228+
}

src/webpack.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ function webpackBuildComplete(stats: any, context: BuildContext, webpackConfig:
9393
Logger.debug('Webpack Dependency Map End');
9494
}
9595

96+
// set the module files used in this bundle
97+
// this reference can be used elsewhere in the build (sass)
98+
if (!context.isProd || !context.optimizeJs) {
99+
const files: string[] = stats.compilation.modules.map((webpackObj: any) => {
100+
if (webpackObj.resource) {
101+
return webpackObj.resource;
102+
} else {
103+
return webpackObj.context;
104+
}
105+
}).filter((path: string) => {
106+
// just make sure the path is not null
107+
return path && path.length > 0;
108+
});
109+
110+
context.moduleFiles = files;
111+
}
112+
96113
return setBundledFiles(context);
97114
}
98115

@@ -227,4 +244,4 @@ export interface WebpackOutputObject {
227244
export interface WebpackResolveObject {
228245
extensions: string[];
229246
modules: string[];
230-
}
247+
}

0 commit comments

Comments
 (0)