Skip to content

Commit 52efa21

Browse files
committed
使用extract-text-webpack-plugin插件,将css文件抽离出单独的文件插入到head标签里面
1 parent 187345e commit 52efa21

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

dist/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
77
<title>司机注册</title>
8+
<link rel="stylesheet" href="style.css">
89
</head>
910

1011
<body>

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"css-loader": "^0.25.0",
2626
"eslint": "^3.8.1",
2727
"eslint-loader": "^1.6.0",
28+
"extract-text-webpack-plugin": "^1.0.1",
2829
"html-loader": "^0.4.4",
2930
"json-loader": "^0.5.4",
3031
"less": "^2.7.1",

webpack.config.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var path = require('path'),
2-
DashboardPlugin = require('webpack-dashboard/plugin');
2+
DashboardPlugin = require('webpack-dashboard/plugin'),
3+
webpack = require('webpack'),
4+
ExtractTextPlugin = require('extract-text-webpack-plugin');
35

46
module.exports ={
57
entry: path.join(__dirname, 'src/index.js'),
@@ -25,15 +27,15 @@ module.exports ={
2527
},
2628
{
2729
test: /\.less$/,
28-
loader: 'style!css!less'
30+
loader: ExtractTextPlugin.extract('style', 'css!less')
2931
},
3032
{
3133
test: /\.html$/,
3234
loader: 'raw'
3335
},
3436
{
3537
test: /\.css$/,
36-
loader: 'style!css'
38+
loader: ExtractTextPlugin.extract('style', 'css')
3739
},
3840
{
3941
test: /\.json$/,
@@ -50,6 +52,7 @@ module.exports ={
5052
extensions: ['', '.js', '.less', '.html', '.json'],
5153
},
5254
plugins: [
53-
new DashboardPlugin()
55+
new DashboardPlugin(),
56+
new ExtractTextPlugin('style.css')
5457
]
5558
}

0 commit comments

Comments
 (0)