Webpack4 packaging cannot extract css into a separate file (mini-css-extract-plugin)

I use the plug-in mini-css-extract-plugin to extract less files and css as separate files, which were introduced during development, but after packaging, they will not generate css files, all in accordance with the online configuration, can anyone help me to answer them? Thank you! It"s the vue project.

introduced screenshot:

clipboard.png

clipboard.png

my full webpack.config.prod.js:

const baseConfig = require("./webpack.config.base")
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const merge = require("webpack-merge")
const path = require("path")
const productionConfig = merge(baseConfig, {
  mode: "production",
  entry: {
    app: path.join(__dirname, "../src/index.js"),
    vendor: ["vue", "vue-router", "vuex", "axios", "element-ui"]
  },
  output: {
    path: path.join(__dirname, "../build/public"),
    filename: "js/[name].bundle.js",
    chunkFilename: "js/[name].[chunkhash:8].chunk.js",
    publicPath: "./public"
  },
  module: {
    rules: [
      {
        test: /\.css/,
        use: [
          MiniCssExtractPlugin.loader,
          "css-loader"
        ],
        include: [
          path.resolve(__dirname, "node_modules")
        ]
      },
      {
        test: /\.less/,
        use: [
          MiniCssExtractPlugin.loader,
          "css-loader",
          "less-loader"
        ],
        include: [
          path.resolve(__dirname, "node_modules")
        ]
      },
      {
        test: /\.(gif|jpg|jpeg|png|svg)$/,
        use: [
          {
            loader: "url-loader",
            options: {
              limit: 1024,
              name: "[name].[hash:8].[ext]",
              publicPath: "./public/img",
              outputPath: "/img"
            }
          }
        ]
      },
      {
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        loader: "file-loader",
        options: {
          limit: 80000,
          name: "[name].[hash:8].[ext]",
          publicPath: "./public/fonts",
          outputPath: "/fonts"
        }
      }
    ]
  },
  optimization: {
    splitChunks: {
      cacheGroups: {
        vendor: {
          test: /[\\/]node_modules[\\/]/,
          name: "vendor",
          chunks: "all"
        }
      }
    },
    runtimeChunk: true
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: "[name].[chunkhash:8].css",
      chunkFilename: "[id].css"
    })
  ]
})
module.exports = productionConfig

I've come across it, too, and the solution is to remove the sideEffects from the package.json.


I think webpack4 is going to use mini-css-extract-plugin instead of extract-text-webpack-plugin.


there is a similar issue:
https://github.com/webpack-co.

.

but a long time ago, I couldn't try it myself. I hope I can help you


the style file should be introduced but not used, it is dropped by tree-shaking directly, and

is added to package.json.
"sideEffects": [
    "*.css",
    "*.scss",
    "*.sass",
    "*.less"
  ]

Brother, how did you solve your problem? The problem I encountered is similar to yours, but I will have no problem if I change mode to development. Production is still the same


the same problem. I can't find the problem. It's awkward

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34d07-2b48f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34d07-2b48f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?