forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): add lazy styles/scripts
Close angular#3401 Close angular#3400
- Loading branch information
1 parent
96852ed
commit 3b78e69
Showing
20 changed files
with
515 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,18 @@ | ||
const path = require('path'); | ||
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | ||
|
||
export const getWebpackDevConfigPartial = function(projectRoot: string, appConfig: any) { | ||
const appRoot = path.resolve(projectRoot, appConfig.root); | ||
const styles = appConfig.styles | ||
? appConfig.styles.map((style: string) => path.resolve(appRoot, style)) | ||
: []; | ||
const cssLoaders = ['style-loader', 'css-loader?sourcemap', 'postcss-loader']; | ||
|
||
return { | ||
output: { | ||
path: path.resolve(projectRoot, appConfig.outDir), | ||
filename: '[name].bundle.js', | ||
sourceMapFilename: '[name].bundle.map', | ||
chunkFilename: '[id].chunk.js' | ||
}, | ||
module: { | ||
rules: [ | ||
// outside of main, load it via style-loader for development builds | ||
{ | ||
include: styles, | ||
test: /\.css$/, | ||
loaders: cssLoaders | ||
}, { | ||
include: styles, | ||
test: /\.styl$/, | ||
loaders: [...cssLoaders, 'stylus-loader?sourcemap'] | ||
}, { | ||
include: styles, | ||
test: /\.less$/, | ||
loaders: [...cssLoaders, 'less-loader?sourcemap'] | ||
}, { | ||
include: styles, | ||
test: /\.scss$|\.sass$/, | ||
loaders: [...cssLoaders, 'sass-loader?sourcemap'] | ||
}, | ||
] | ||
} | ||
plugins: [ | ||
new ExtractTextPlugin({filename: '[name].bundle.css'}) | ||
] | ||
}; | ||
}; |
Oops, something went wrong.