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

Fixed %sapper.styles% injection for webpack apps #622

Merged
merged 2 commits into from
Apr 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/core/create_compilers/WebpackResult.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import format_messages from 'webpack-format-messages';
import { CompileResult, BuildInfo, CompileError, Chunk, CssFile } from './interfaces';
import { ManifestData, Dirs } from '../../interfaces';
import { ManifestData, Dirs, PageComponent } from '../../interfaces';

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

Expand Down Expand Up @@ -66,12 +66,15 @@ export default class WebpackResult implements CompileResult {
assets: this.assets,
css: {
main: extract_css(this.assets.main),
chunks: Object
.keys(this.assets)
.filter(chunkName => chunkName !== 'main')
.reduce((chunks: { [key: string]: string }, chukName) => {
const assets = this.assets[chukName];
chunks[chukName] = extract_css(assets);
chunks: manifest_data.components
.reduce((chunks: Record<string, string[]>, component: PageComponent) => {
const css_dependencies = [];
const css = extract_css(this.assets[component.name]);

if (css) css_dependencies.push(css);

chunks[component.file] = css_dependencies;

return chunks;
}, {})
}
Expand All @@ -81,4 +84,4 @@ export default class WebpackResult implements CompileResult {
print() {
return this.stats.toString({ colors: true });
}
}
}