1. 程式人生 > >vue文件單獨打包css

vue文件單獨打包css

生產 插件 tool pre del style true plugin rac

單獨打包需要使用extract-text-webpack-plugin插件;

[email protected],webpack用的webpack2

配置如下:

1.先定義 const ExtractTextPlugin = require(‘extract-text-webpack-plugin‘);

2.配置css和less

{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback:‘style-loader‘,
use:‘css-loader‘
})
},
{
test: /\.less$/,
use: ExtractTextPlugin.extract({
fallbackLoader: ‘style-loader‘,
use:[{
loader: ‘css-loader‘,
options: { sourceMap: true, importLoaders: 1 }
},{
loader: ‘less-loader‘,
options: { sourceMap: true }
}]

})

},

3.添加plugins

new ExtractTextPlugin(‘css/styles.css‘)

4.記得修改devtool: ‘source-map‘

5.查看是什麽模式,開發模式還是生產模式,生產模式才會打包










 

vue文件單獨打包css