码迷,mamicode.com
首页 > Web开发 > 详细

vue文件单独打包css

时间:2017-08-22 18:46:53      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:ttext   webp   pac   llb   ack   plugin   text   tool   版本   

单独打包需要使用extract-text-webpack-plugin插件;

我用的extract-text-webpack-plugin@2.1.2这个版本,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

标签:ttext   webp   pac   llb   ack   plugin   text   tool   版本   

原文地址:http://www.cnblogs.com/liuhuanwen/p/7412872.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!