vue-cli icon indicating copy to clipboard operation
vue-cli copied to clipboard

Can't npm run build on new projects due to mini-css-extract-plugin

Open korggy opened this issue 4 years ago • 1 comments

Versions

Windows 11 @vue/[email protected] [email protected]

Steps to reproduce

  1. In Powershell, run vue ui
  2. Create new project. Accept all defaults, manually select all features off, Vue 2.x.
  3. Switch to Tasks / serve page. Verify Run task works properly (it should).
  4. Switch to Tasks / build page. Run task returns an error: Syntax Error: Error: You forgot to add 'mini-css-extract-plugin' plugin (i.e. { plugins: [new MiniCssExtractPlugin()] }), please read https://github.com/webpack-contrib/mini-css-extract-plugin#getting-started

Expected behavior

New projects should build successfully out of the box.

Workarounds

Workaround 1: Turn off Extract CSS in configuration. This corrects the build problem but does not create standalone CSS files.

  1. Switch to Configuration page.
  2. Switch Extract CSS to off
  3. Save changes

Workaround 2: Manually add mini-css-extract-plugin and reconfigure the project.

  1. Add mini-css-extract-plugin as a development dependency.
  2. Add a vue.config.js file with the following content:
// vue.config.js
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
  configureWebpack: {
    plugins: [new MiniCssExtractPlugin()],
  }
};

korggy avatar Jun 07 '22 14:06 korggy

Hello, thank you for taking time filling this issue!

However, we kindly ask you to use our Issue Helper when creating new issues, in order to ensure every issue provides the necessary information for us to investigate. This explains why your issue has been automatically closed by me (your robot friend!).

I hope to see your helper-created issue very soon!

vue-bot avatar Jun 07 '22 14:06 vue-bot