Reputation:
I'm trying install npm install --save \ mini-css-extract-plugin \ css-loader but i'm getting this error in my webpack,can someone help me out with whats the issue here? is it webpack ver or the node_modules
?
package.json
"devDependencies": {
"postcss-loader": "^3.0.0",
"raw-loader": "^4.0.1",
"style-loader": "^1.2.1",
"terser-webpack-plugin": "^3.0.2",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
}
Error
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: @ckeditor/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR! dev webpack@"^4.43.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^5.0.0" from [email protected]
npm ERR! node_modules/mini-css-extract-plugin
npm ERR! mini-css-extract-plugin@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
UPDATE:
webpack.config.js
const path = require( 'path' );
const webpack = require( 'webpack' );
const { bundler, styles } = require( '@ckeditor/ckeditor5-dev-utils' );
const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin' );
const TerserPlugin = require( 'terser-webpack-plugin' );
module.exports = {
devtool: 'source-map',
performance: { hints: false },
entry: path.resolve( __dirname, 'src', 'ckeditor.js' ),
output: {
// The name under which the editor will be exported.
library: 'DecoupledEditor',
path: path.resolve( __dirname, 'build' ),
filename: 'ckeditor.js',
libraryTarget: 'umd',
libraryExport: 'default'
},
optimization: {
minimizer: [
new TerserPlugin( {
sourceMap: true,
terserOptions: {
output: {
// Preserve CKEditor 5 license comments.
comments: /^!/
}
},
extractComments: false
} )
]
},
plugins: [
new CKEditorWebpackPlugin( {
// UI language. Language codes follow the https://en.wikipedia.org/wiki/ISO_639-1 format.
// When changing the built-in language, remember to also change it in the editor's configuration (src/ckeditor.js).
language: 'en',
additionalLanguages: 'all'
} ),
new webpack.BannerPlugin( {
banner: bundler.getLicenseBanner(),
raw: true
} )
],
module: {
rules: [
{
test: /\.svg$/,
use: [ 'raw-loader' ]
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
options: {
injectType: 'singletonStyleTag',
attributes: {
'data-cke': true
}
}
},
{
loader: 'postcss-loader',
options: styles.getPostCssConfig( {
themeImporter: {
themePath: require.resolve( '@ckeditor/ckeditor5-theme-lark' )
},
minify: true
} )
}
]
}
]
}
};
Upvotes: 0
Views: 2536
Reputation: 331
MiniCssExtractPlugin requires webpack 5 to work.
Starting from version 2.0.0 minimum supported webpack version is 5.0.0
As an option, you can try to use MiniCssExtractPlugin version 1.6.2. Also consider upgrading to webpack5, but raw-loader plugin is deprecated as well as terser-webpack-plugin
Upvotes: 2