Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 01c0097

Browse files
authored
Fixed %sapper.styles% injection for webpack builds
1 parent 7be7e1e commit 01c0097

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/core/create_compilers/WebpackResult.ts

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import format_messages from 'webpack-format-messages';
22
import { CompileResult, BuildInfo, CompileError, Chunk, CssFile } from './interfaces';
3-
import { ManifestData, Dirs } from '../../interfaces';
3+
import { ManifestData, Dirs, PageComponent } from '../../interfaces';
44

55
const locPattern = /\((\d+):(\d+)\)$/;
66

@@ -66,19 +66,22 @@ export default class WebpackResult implements CompileResult {
6666
assets: this.assets,
6767
css: {
6868
main: extract_css(this.assets.main),
69-
chunks: Object
70-
.keys(this.assets)
71-
.filter(chunkName => chunkName !== 'main')
72-
.reduce((chunks: { [key: string]: string }, chukName) => {
73-
const assets = this.assets[chukName];
74-
chunks[chukName] = extract_css(assets);
75-
return chunks;
76-
}, {})
69+
chunks: manifest_data.components
70+
.reduce((chunks: Record<string, string[]>, component: PageComponent) => {
71+
const css_dependencies = [];
72+
const css = extract_css(this.assets[component.name]);
73+
74+
if (css) css_dependencies.push(css);
75+
76+
chunks[component.file] = css_dependencies;
77+
78+
return chunks;
79+
}, {})
7780
}
7881
};
7982
}
8083

8184
print() {
8285
return this.stats.toString({ colors: true });
8386
}
84-
}
87+
}

0 commit comments

Comments
 (0)