Skip to content

Upgrading css-loader 3 to 4

Breaking3.6.0 → 4.3.0Breaking12Platform1New9Changed3Fixed6

BreakingUpgrade verdict

12 breaking changes and a platform requirement change.

  • CSS modules now emit ES modules by default instead of CommonJS.
  • Whether source maps are generated now follows your webpack devtool setting.
  • ICSS handling is off unless you configure the modules option.
  • The option controlling the base path for local class names has a new name.
Top 4 of 13 that need code or config changes

Node.js requirement changed in 4.0.0: >= 8.9.0 → >= 10.13.0.

Drops normalize-path.

Installs 27 packages in all (was 29).

Breaking12
Makes the esModule option true by default.
esModule
Makes the default value of the sourceMap option depend on the devtool option.
sourceMapdevtool
Disables the icss plugin by default; the modules option must be set up to enable it.
icssmodules
Renames the modules.context option to modules.localIdentContext.
modules.contextmodules.localIdentContext
Defaults modules.localIdentContext to compiler.context for the module.getLocalIdent option.
modules.localIdentContextcompiler.contextmodule.getLocalIdent
Renames the modules.hashPrefix option to modules.localIdentHashPrefix.
modules.hashPrefixmodules.localIdentHashPrefix
Moves and renames the localsConvention option to modules.exportLocalsConvention.
localsConventionmodules.exportLocalsConvention
Moves and renames the onlyLocals option to modules.exportOnlyLocals.
onlyLocalsmodules.exportOnlyLocals
Enables the modules option by default for files matching /\\.module\\.\w+$/i.test(filename), with module.auto true by default.
modulesmodule.auto
Requires the getLocalIndent option to always be a Function returning a String value.
getLocalIndent
Changes the arguments of the import option function to function(url, media, resourcePath) {}.
import
Changes inline syntax so ~ is written before the file request.
Platform1
Raises the minimum required Node.js version to 10.13.0.