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

Commit

Permalink
Merge pull request #529 from artemjackson/master
Browse files Browse the repository at this point in the history
Added css build info for webpack apps
  • Loading branch information
Rich-Harris authored Dec 9, 2018
2 parents af0a7e0 + e7cf9bf commit abd2f7f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/core/create_compilers/WebpackResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,25 @@ export default class WebpackResult implements CompileResult {
}

to_json(manifest_data: ManifestData, dirs: Dirs): BuildInfo {
const extract_css = (assets: string[] | string) => {
assets = Array.isArray(assets) ? assets : [assets];
return assets.find(asset => /\.css$/.test(asset));
};

return {
bundler: 'webpack',
shimport: null, // webpack has its own loader
assets: this.assets,
css: {
// TODO
main: null,
chunks: {}
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);
return chunks;
}, {})
}
};
}
Expand Down

0 comments on commit abd2f7f

Please sign in to comment.