This commit is contained in:
Richard Harris
2019-04-21 13:30:48 -04:00
parent 83c8d7f855
commit 81553df7cb

View File

@@ -1,6 +1,6 @@
import format_messages from 'webpack-format-messages'; import format_messages from 'webpack-format-messages';
import { CompileResult, BuildInfo, CompileError, Chunk, CssFile } from './interfaces'; import { CompileResult, BuildInfo, CompileError, Chunk, CssFile } from './interfaces';
import { ManifestData, Dirs } from '../../interfaces'; import { ManifestData, Dirs, PageComponent } from '../../interfaces';
const locPattern = /\((\d+):(\d+)\)$/; const locPattern = /\((\d+):(\d+)\)$/;
@@ -9,7 +9,7 @@ function munge_warning_or_error(message: string) {
const lines = message.split('\n'); const lines = message.split('\n');
const file = lines.shift() const file = lines.shift()
.replace('', '') // careful — there is a special character at the beginning of this string .replace('', '') // careful — there is a special character at the beginning of this string
.replace('', '') .replace('', '')
.replace('./', ''); .replace('./', '');
@@ -66,12 +66,15 @@ export default class WebpackResult implements CompileResult {
assets: this.assets, assets: this.assets,
css: { css: {
main: extract_css(this.assets.main), main: extract_css(this.assets.main),
chunks: Object chunks: manifest_data.components
.keys(this.assets) .reduce((chunks: Record<string, string[]>, component: PageComponent) => {
.filter(chunkName => chunkName !== 'main') const css_dependencies = [];
.reduce((chunks: { [key: string]: string }, chukName) => { const css = extract_css(this.assets[component.name]);
const assets = this.assets[chukName];
chunks[chukName] = extract_css(assets); if (css) css_dependencies.push(css);
chunks[component.file] = css_dependencies;
return chunks; return chunks;
}, {}) }, {})
} }