Closed pmurphy-cs closed 3 years ago
For maintainers only:
Not related to webpack itself, please open an issue in resolve-url-loader
or please use discussion and provide example of repo and I will look and say where problem. Problems with url
in sass/scss described here https://github.com/webpack-contrib/sass-loader#problems-with-url and resolve-url-loader
have a lot of limitation, I strongly recommend do not use resolve-url-loader
.
You can put link on source code here or provide example of the problem. But I am closing because webpack don't touch your CSS files.
Also please remove webpack.optimize.ModuleConcatenationPlugin
from configuration, two plugins will break your JS, it is enabled by default in production
mode
Nothing from optimizations/plugins
do not change your url
in CSS
Hey @alexander-akait , thanks for the quick reply.
By any chance do you have a list of the config changes that the mode flag will make for "production" | "development" | "none" in webpack 5? It appears the current documentation no longer accurately reflects what will be enabled/disabled
@pmurphy-cs just more plugins for JS optimization, but it is 99.99% is not a problem for you here, none of these plugins touch url
in CSS
Sets process.env.NODE_ENV on DefinePlugin to value production. Enables deterministic mangled names for modules and chunks, FlagDependencyUsagePlugin, FlagIncludedChunksPlugin, ModuleConcatenationPlugin, NoEmitOnErrorsPlugin and TerserPlugin.
It is right
Bug report
What is the current behavior?
Enabling production mode breaks url resolution/resolve-url-loader for scss files calling scss files in another directory containing url(...).
Here's an example of the directory structure/import order that's currently failing (dir/filenames changed to protect the innocent)
src | - css | - base | - fileWhereUrlIsActuallyBeingUsed.scss | - imgThatIsImported.png | - styleAtoms | - typeOfAtom | - file2.scss
| - js | - common | - componentStyles | - file3.scss | - app | - styles | fileThatWebpackThinksIsInRootFolder.scss
import order: fileThatWebpackThinksIsInRootFolder.scss -> file3.scss -> file2.scss -> fileWhereUrlIsActuallyBeingUsed.scss
This import chain works fine in development mode, and was working in production mode when we were on Webpack 4. After upgrading to WP5, it no longer works in production mode, and instead of looking for imgThatIsImported.png in src/css/base, the build is erroring out because it's expecting it in src/js/app/styles
Furthermore, if we follow the official mode documentation here, https://webpack.js.org/configuration/mode/#root, and manually enable all of the documented optimizations/plugins that production mode should enable, our build still passes when the mode flag is set to 'none' or 'development'. This makes it seem as if the documentation for what the mode settings generate for a config is currently out of date.
If the current behavior is a bug, please provide the steps to reproduce.
We have 3 webpack configs, common, dev, and prod
What is the expected behavior?
urls in .scss files that are called by other .scss files that don't share the same parent directory should still resolve properly in production mode in webpack 5
At the very least, mode documentation should be updated to reflect the exact config changes that each mode makes in webpack 5 so that devs can at least troubleshoot optimizations/plugins in an informed way.
Other relevant information: webpack version: 5.35.1 Node.js version: 14.17.0 Operating System: Windows 10 Additional tools: