ITPub博客

首页 > 应用开发 > > 使用webpack4打包提取不出css文件

使用webpack4打包提取不出css文件

作者:deeply 时间:2019-08-02 14:58:42 0 删除 编辑

使用的是 

mini-css-extract-plugin  这个插件,来提取的,下面是我的配置

const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
 
function resolve(dir) {return path.join(__dirname, '..', dir)}
 
module.exports = {
entry: {
    index: './src/pages/index/js/index.js',fang: './src/pages/fang_list/js/fang_list.js'},
    output: {filename: 'js/[name].[chunkhash:8].js',path: resolve('dist')},
     plugins: [
     new CleanWebpackPlugin(['dist'],{
     root: resolve('./'),
     verbose:true,
     dry:false}),
     new HTMLWebpackPlugin({
     template:'src/pages/index/index.html',
     filename: 'index.html',chunks: ['index']}),
     new HTMLWebpackPlugin({
     template:'src/pages/fang_list/fang_list.html',filename: 'fang_list.html',chunks: ['fang']}),
     new MiniCssExtractPlugin({filename: "[name].css",chunkFilename: "[id].css"})],
     module: {
     rules: [
     {test: /\.js$/,loader: 'babel-loader'},
     {test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,loader: 'url-loader',options: {limit: 10000}},
     {test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,loader: 'url-loader',options: {limit: 10000,}},
     test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,loader: 'url-loader',options: {limit: 10000,}},
     {test: /\.css$/,use: [MiniCssExtractPlugin.loader,"css-loader"]},
     {test:/\.less$/,use: [MiniCssExtractPlugin.loader,'css-loader','less-loader']}]}}


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1978/viewspace-3126967/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: Sql并发问题
请登录后发表评论 登录
全部评论

注册时间:2008-05-30

  • 博文量
    215
  • 访问量
    24532