Skip to content

Commit acd06b3

Browse files
committed
Use extract-text-plugin to bundle all styles
1 parent 6dbe180 commit acd06b3

File tree

4 files changed

+19
-36
lines changed

4 files changed

+19
-36
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"exit": "^0.1.2",
6666
"exports-loader": "^0.6.3",
6767
"expose-loader": "^0.7.1",
68-
"extract-loader": "^0.0.2",
68+
"extract-text-webpack-plugin": "^2.0.0-beta.4",
6969
"file-loader": "^0.8.5",
7070
"fs-extra": "^0.30.0",
7171
"fs.realpath": "^1.0.0",

packages/angular-cli/models/webpack-build-common.ts

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {GlobCopyWebpackPlugin} from '../plugins/glob-copy-webpack-plugin';
44
import {BaseHrefWebpackPlugin} from '@angular-cli/base-href-webpack';
55

66
const HtmlWebpackPlugin = require('html-webpack-plugin');
7-
7+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
88

99
export function getWebpackCommonConfig(
1010
projectRoot: string,
@@ -71,46 +71,26 @@ export function getWebpackCommonConfig(
7171
loaders: ['raw-loader', 'postcss-loader', 'sass-loader']
7272
},
7373

74-
// outside of main, extract static css files using extract and file loaders.
74+
// outside of main, extract static css files using extract-text-plugin
7575
       {
7676
include: styles,
7777
test: /\.css$/,
78-
loaders: [
79-
'file-loader?name=[name].css',
80-
'extract-loader',
81-
'css-loader',
82-
'postcss-loader'
83-
]
84-
}, {
78+
loader: ExtractTextPlugin.extract(['css-loader', 'postcss-loader'])
79+
},
80+
{
8581
include: styles,
8682
test: /\.styl$/,
87-
loaders: [
88-
'file-loader?name=[name].css',
89-
'extract-loader',
90-
'css-loader',
91-
'postcss-loader',
92-
'stylus-loader'
93-
]
94-
}, {
83+
loader: ExtractTextPlugin.extract(['css-loader', 'postcss-loader', 'stylus-loader'])
84+
},
85+
{
9586
include: styles,
9687
test: /\.less$/,
97-
loaders: [
98-
'file-loader?name=[name].css',
99-
'extract-loader',
100-
'css-loader',
101-
'postcss-loader',
102-
'less-loader'
103-
]
104-
}, {
88+
loader: ExtractTextPlugin.extract(['css-loader', 'postcss-loader', 'less-loader'])
89+
},
90+
{
10591
include: styles,
10692
test: /\.scss$|\.sass$/,
107-
loaders: [
108-
'file-loader?name=[name].css',
109-
'extract-loader',
110-
'css-loader',
111-
'postcss-loader',
112-
'sass-loader'
113-
]
93+
loader: ExtractTextPlugin.extract(['css-loader', 'postcss-loader', 'sass-loader'])
11494
},
11595

11696
// load global scripts using script-loader
@@ -130,6 +110,9 @@ export function getWebpackCommonConfig(
130110
template: path.resolve(appRoot, appConfig.index),
131111
chunksSortMode: 'dependency'
132112
}),
113+
new ExtractTextPlugin(environment === 'prod'
114+
? '[name].[contenthash].bundle.css'
115+
: '[name].bundle.css'),
133116
new BaseHrefWebpackPlugin({
134117
baseHref: baseHref
135118
}),

packages/angular-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"exit": "^0.1.2",
4949
"exports-loader": "^0.6.3",
5050
"expose-loader": "^0.7.1",
51-
"extract-loader": "^0.0.2",
51+
"extract-text-webpack-plugin": "^2.0.0-beta.4",
5252
"file-loader": "^0.8.5",
5353
"fs-extra": "^0.30.0",
5454
"fs.realpath": "^1.0.0",

tests/e2e/tests/build/styles/css.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ export default function() {
1414
`
1515
})
1616
.then(() => ng('build'))
17-
.then(() => expectFileToMatch('dist/styles.css', 'body { background-color: blue; }'))
18-
.then(() => expectFileToMatch('dist/styles.css', 'p { background-color: red; }'));
17+
.then(() => expectFileToMatch('dist/styles.bundle.css', 'body { background-color: blue; }'))
18+
.then(() => expectFileToMatch('dist/styles.bundle.css', 'p { background-color: red; }'));
1919
}

0 commit comments

Comments
 (0)