鍍金池/ 問(wèn)答/HTML5  HTML/ webpack3 中 用 extract-text-webpack-plugin

webpack3 中 用 extract-text-webpack-plugin 打包時(shí)提出css出來(lái),沒(méi)有css文件

var webpack = require('webpack');
var merge = require('@ersinfotech/merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
//加載JS模塊壓縮編譯插件
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
var webpackConfig = require('./webpack.config');
const CleanWebpackPlugin = require('clean-webpack-plugin');
var path = require('path');
process.env.NODE_ENV = 'production';

var utils = require('./utils');

const productionConfig = {
    devtool: 'cheap-module-source-map',
    module: {
        loaders: [
            { test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader", {publicPath:'../'}) },
            { test: /\.less$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader!less-loader', {publicPath:'../'}) },
        ]
    },
    plugins: [
        new CleanWebpackPlugin(['dist/*.*']),
        new webpack.optimize.UglifyJsPlugin(),
        new webpack.DefinePlugin({
            'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production')
        }),
        new ExtractTextPlugin('css/[name].[contenthash].css', {allChunks: true}), // 單獨(dú)打包CSS
    ]
}

module.exports = merge(webpackConfig, productionConfig);

以上是代碼 ,有大神知道 ,除了上面的配置,還有什么地方需要 配置一下嘛, 現(xiàn)在打包是成功,但是css還是跟js 打包在一起。

 import './main.less'

在項(xiàng)目中是這樣引入了。

extract-text-webpack-plugin 版本是 3.0.0.

有哪位大神配置過(guò),指導(dǎo)一下。

回答
編輯回答
貓小柒

clipboard.png你加上這個(gè),名字你看著改

2017年4月18日 11:30