extract-text-webpack-plugin插件提取css单独打包

安装方法:
npm install extract-text-webpack-plugin –save-dev
使用:

const ExtractTextPlugin = require('extract-text-webpack-plugin')//引入
module.exports = {
     plugins: [
        new ExtractTextPlugin({
            filename: 'css/[name].css' //路径以及命名
        })
     ],
     module: {
        rules: [
            {
                test: /\.vue$/,
                loader: 'vue-loader',
                options: {
                    loaders: {
                        less: ExtractTextPlugin.extract({ fallback: 'vue-style-loader', use: 'css-loader!less-loader' }),
                        css: ExtractTextPlugin.extract({ fallback: 'vue-style-loader', use: 'css-loader' })
                    }
                    // other vue-loader options go here
                }
            },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }),
                exclude: /node_modules/,
            }
      ]
}

你可能感兴趣的:(vue踩坑记录)