Skip to content

Commit ff7157a

Browse files
committed
Modify the webpack configuration to extracting CSS into a single file
1 parent cec7e6b commit ff7157a

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

app/templates/_index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title><%= appname %></title>
6+
<link rel="stylesheet" href="dist/bundle.css">
67
</head>
78
<body>
89
<app></app>

app/templates/_package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"eslint-plugin-import": "^1.6.0",
2424
"eslint-plugin-jsx-a11y": "^1.0.3",
2525
"eslint-plugin-react": "^5.0.1",
26+
"extract-text-webpack-plugin": "^1.0.1",
2627
"file-loader": "^0.8.5",
2728
"html-webpack-plugin": "^2.16.0",
2829
"less": "^2.6.1",

app/templates/_webpack.config.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var webpack = require('webpack');
2+
var ExtractTextPlugin = require("extract-text-webpack-plugin");
23

34
module.exports = {
45
entry: './src/main.js',
@@ -44,11 +45,20 @@ module.exports = {
4445
}
4546
}
4647
]
47-
}
48+
},
49+
vue: {
50+
loaders: {
51+
css: ExtractTextPlugin.extract('css'),
52+
less: ExtractTextPlugin.extract('css!less')
53+
}
54+
},
55+
plugins: [
56+
new ExtractTextPlugin("bundle.css")
57+
]
4858
};
4959

5060
if (process.env.NODE_ENV === 'production') {
51-
module.exports.plugins = [
61+
module.exports.plugins = module.exports.plugins.concat([
5262
new webpack.DefinePlugin({
5363
'process.env': {
5464
NODE_ENV: '"production"'
@@ -60,12 +70,10 @@ if (process.env.NODE_ENV === 'production') {
6070
}
6171
}),
6272
new webpack.optimize.OccurenceOrderPlugin()
63-
];
73+
]);
6474

65-
module.exports.vue = {
66-
autoprefixer: {
67-
browsers: ['last 2 versions']
68-
}
75+
module.exports.vue.autoprefixer = {
76+
browsers: ['last 2 versions']
6977
}
7078
} else {
7179
module.exports.devtool = '#source-map';

0 commit comments

Comments
 (0)