From c2567d8034e524f27a84054c41ca557525c762fa Mon Sep 17 00:00:00 2001 From: smouillour Date: Fri, 13 Oct 2023 10:06:46 +0200 Subject: [PATCH] fix all loaders --- packages/icons/webpack.config.js | 6 +++--- packages/storybook-docs/webpack.custom.js | 14 ++++++++++---- packages/theme/webpack.config.js | 10 +++++----- .../config/webpack.config.common.js | 12 +++++++----- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/packages/icons/webpack.config.js b/packages/icons/webpack.config.js index 79f91dd811..370970eeb2 100644 --- a/packages/icons/webpack.config.js +++ b/packages/icons/webpack.config.js @@ -27,14 +27,14 @@ module.exports = { { // The replacer is used to create relative local paths instead of paths relative // to publicPath, because it makes it processable by webpack. - loader: 'string-replace-loader', + loader: require.resolve('string-replace-loader'), options: { search: /url\(\\"\//g, // The CSS output by css-loader is stringified, so the quotes are escaped replace: 'url(\\"./', }, }, { - loader: 'css-loader', + loader: require.resolve('css-loader'), options: { url: false, }, @@ -44,7 +44,7 @@ module.exports = { }, { test: /\.(woff|eot|ttf|svg)$/, - loader: 'url-loader', + loader: require.resolve('url-loader'), }, ], }, diff --git a/packages/storybook-docs/webpack.custom.js b/packages/storybook-docs/webpack.custom.js index 73c46a8a9b..06526b8dca 100644 --- a/packages/storybook-docs/webpack.custom.js +++ b/packages/storybook-docs/webpack.custom.js @@ -20,9 +20,12 @@ module.exports = { exclude: /node_modules/, use: [ { loader: MiniCssExtractPlugin.loader, options: { esModule: false } }, - { loader: 'css-loader', options: { sourceMap: true } }, { - loader: 'postcss-loader', + loader: require.resolve('css-loader'), + options: { sourceMap: true }, + }, + { + loader: require.resolve('postcss-loader'), options: { postcssOptions: { plugins: ['autoprefixer'], @@ -30,9 +33,12 @@ module.exports = { }, }, }, - { loader: 'resolve-url-loader', options: { sourceMap: true } }, { - loader: 'sass-loader', + loader: require.resolve('resolve-url-loader'), + options: { sourceMap: true }, + }, + { + loader: require.resolve('sass-loader'), options: { sourceMap: true }, }, ], diff --git a/packages/theme/webpack.config.js b/packages/theme/webpack.config.js index ccf1f08de1..2ffb9d6c2d 100644 --- a/packages/theme/webpack.config.js +++ b/packages/theme/webpack.config.js @@ -25,7 +25,7 @@ module.exports = (env, argv) => { test: /\.woff(2)?(\?[a-z0-9=&.]+)?$/, use: [ { - loader: 'file-loader', + loader: require.resolve('file-loader'), options: { outputPath: 'fonts', name: '[name].[ext]', @@ -38,17 +38,17 @@ module.exports = (env, argv) => { test: /bootstrap\.scss$/, use: [ { - loader: isDev ? 'style-loader' : MiniCssExtractPlugin.loader, + loader: isDev ? require.resolve('style-loader') : MiniCssExtractPlugin.loader, }, { - loader: 'css-loader', + loader: require.resolve('css-loader'), options: { importLoaders: 3, sourceMap: true, }, }, { - loader: 'postcss-loader', + loader: require.resolve('postcss-loader'), options: { postcssOptions: { plugins: [postcssPresetEnv({ browsers: 'last 2 versions' })], @@ -57,7 +57,7 @@ module.exports = (env, argv) => { }, }, { - loader: 'sass-loader', + loader: require.resolve('sass-loader'), options: { sourceMap: true, }, diff --git a/tools/scripts-config-react-webpack/config/webpack.config.common.js b/tools/scripts-config-react-webpack/config/webpack.config.common.js index b17399ae82..18b78c1e0a 100644 --- a/tools/scripts-config-react-webpack/config/webpack.config.common.js +++ b/tools/scripts-config-react-webpack/config/webpack.config.common.js @@ -39,12 +39,14 @@ function getCommonStyleLoaders(enableModules, isEnvDevelopmentServe) { importLoaders: 1, }; } - const styleLoader = isEnvDevelopmentServe ? 'style-loader' : MiniCssExtractPlugin.loader; + const styleLoader = isEnvDevelopmentServe + ? require.resolve('style-loader') + : MiniCssExtractPlugin.loader; return [ { loader: styleLoader, options: { esModule: false } }, - { loader: 'css-loader', options: cssOptions }, + { loader: require.resolve('css-loader'), options: cssOptions }, { - loader: 'postcss-loader', + loader: require.resolve('postcss-loader'), options: { postcssOptions: { plugins: ['autoprefixer'], @@ -67,9 +69,9 @@ function getJSAndTSLoader() { function getSassLoaders(enableModules, sassData, isEnvDevelopmentServe) { const sourceMap = true; return getCommonStyleLoaders(enableModules, isEnvDevelopmentServe).concat( - { loader: 'resolve-url-loader', options: { sourceMap } }, + { loader: require.resolve('resolve-url-loader'), options: { sourceMap } }, { - loader: 'sass-loader', + loader: require.resolve('sass-loader'), options: { sourceMap, additionalData: sassData }, }, );