mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-16 12:54:38 +00:00
Merge pull request #622 from artemjackson/patch-2
Fixed %sapper.styles% injection for webpack apps
This commit is contained in:
@@ -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+)\)$/;
|
||||||
|
|
||||||
@@ -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;
|
||||||
}, {})
|
}, {})
|
||||||
}
|
}
|
||||||
@@ -81,4 +84,4 @@ export default class WebpackResult implements CompileResult {
|
|||||||
print() {
|
print() {
|
||||||
return this.stats.toString({ colors: true });
|
return this.stats.toString({ colors: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user