vue-cli
vue-cli copied to clipboard
Can't npm run build on new projects due to mini-css-extract-plugin
Versions
Windows 11 @vue/[email protected] [email protected]
Steps to reproduce
- In Powershell, run
vue ui - Create new project. Accept all defaults, manually select all features off, Vue 2.x.
- Switch to Tasks / serve page. Verify Run task works properly (it should).
- 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.
- Switch to Configuration page.
- Switch
Extract CSSto off - Save changes
Workaround 2: Manually add mini-css-extract-plugin and reconfigure the project.
- Add mini-css-extract-plugin as a development dependency.
- 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()],
}
};
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!