Releases: webpack/style-loader
Releases · webpack/style-loader
v4.0.0
4.0.0 (2024-04-08)
⚠ BREAKING CHANGES
- minimum supported webpack version is
5.27.0 - minimum support Node.js version is
18.12.0 - the
insertoption can only be a selector or the path to the module
Migration:
Before:
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.css$/i,
use: [
{
loader: "style-loader",
options: {
injectType: "styleTag",
styleTagTransform: function (css, style) {
// Do something ...
style.innerHTML = `${css}.modify{}\n`;
document.head.appendChild(style);
},
},
},
"css-loader",
],
},
],
},
};After:
insert-function.js
function insert(css, style) {
var parent = options.target || document.head;
parent.appendChild(element);
}
module.exports = insert;webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.css$/i,
use: [
{
loader: "style-loader",
options: {
insert: require.resolve("./insert.js"),
},
},
"css-loader",
],
},
],
},
};- the
styleTagTransformoption can only be the path to the module
Migration:
Before:
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.css$/i,
use: [
{
loader: "style-loader",
options: {
injectType: "styleTag",
styleTagTransform: function (css, style) {
// Do something ...
style.innerHTML = `${css}.modify{}\n`;
document.head.appendChild(style);
},
},
},
"css-loader",
],
},
],
},
};After:
style-tag-transform-function.js
function styleTagTransform(css, style) {
// Do something ...
style.innerHTML = `${css}.modify{}\n`;
document.head.appendChild(style);
}
module.exports = styleTagTransform;webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.css$/i,
use: [
{
loader: "style-loader",
options: {
styleTagTransform: require.resolve("./style-tag-transform-function.js"),
},
},
"css-loader",
],
},
],
},
};Bug Fixes
v3.3.4
v3.3.3
v3.3.2
v3.3.1
v3.3.0
v3.2.1
v3.2.0
v3.1.0
3.1.0 (2021-07-12)
Features
- allow to specify the
insertoption from file, we strongly recommend do it, using theinsertoption from file will reduce your bundle size, example (#521) (56fc8f0) - allow to specify the
styleTagTransformoption from file, we strongly recommend do it, using thestyleTagTransformoption from file will reduce your bundle size, example
Bug Fixes
v3.0.0
3.0.0 (2021-06-24)
⚠ BREAKING CHANGES
- minimum supported
Node.jsversion is12.13.0 - minimum supported
webpackversion is5.0.0 - the
modules.namedExportoption was removed, you don't need it anymore, because we respect themodules.namedExportoption fromcss-loader(we just reexport all fromcss-loader), just remove it - the
styleTagvalue of theinjectType(default value) option earlier uses singleton style tag by default for IE8-IE9 due limitations (more information), in this release we have disabled this behavior, because these versions of IE are outdated, if you don't support these browsers this change does not affect you, if you require to support IE8-IE9, you can return old behaviour by settingautoStyleTagvalue for theinjectTypeoption (do the same forlazyStyleTag, i.e. change it tolazyAutoStyleTag)
Features
- added
autoStyleTagandlazyAutoStyleTagvalues for theinjectTypeoption for compatibility of work modern and IE8-IE9 browsers - added
styleTagTransformoption for custom processing style tags (useful if you need ponyfill CSS custom properties for IE8-IE10) - reduce size of generated code
- reduce deps