Skip to content

Commit 091d37d

Browse files
chore(release): 4.0.0
1 parent abc0b5f commit 091d37d

File tree

3 files changed

+159
-3
lines changed

3 files changed

+159
-3
lines changed

CHANGELOG.md

+156
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,162 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [4.0.0](https://github.com/webpack-contrib/style-loader/compare/v3.3.3...v4.0.0) (2024-04-08)
6+
7+
8+
### ⚠ BREAKING CHANGES
9+
10+
* minimum supported webpack version is `5.27.0`
11+
* minimum support Node.js version is `18.12.0`
12+
* the `insert` option can only be a selector or the path to the module
13+
14+
Migration:
15+
16+
Before:
17+
18+
**webpack.config.js**
19+
20+
```js
21+
module.exports = {
22+
module: {
23+
rules: [
24+
{
25+
test: /\.css$/i,
26+
use: [
27+
{
28+
loader: "style-loader",
29+
options: {
30+
injectType: "styleTag",
31+
styleTagTransform: function (css, style) {
32+
// Do something ...
33+
style.innerHTML = `${css}.modify{}\n`;
34+
35+
document.head.appendChild(style);
36+
},
37+
},
38+
},
39+
"css-loader",
40+
],
41+
},
42+
],
43+
},
44+
};
45+
```
46+
47+
After:
48+
49+
**insert-function.js**
50+
51+
```js
52+
function insert(css, style) {
53+
var parent = options.target || document.head;
54+
55+
parent.appendChild(element);
56+
}
57+
58+
module.exports = insert;
59+
```
60+
61+
**webpack.config.js**
62+
63+
```js
64+
module.exports = {
65+
module: {
66+
rules: [
67+
{
68+
test: /\.css$/i,
69+
use: [
70+
{
71+
loader: "style-loader",
72+
options: {
73+
insert: require.resolve("./insert.js"),
74+
},
75+
},
76+
"css-loader",
77+
],
78+
},
79+
],
80+
},
81+
};
82+
```
83+
84+
* the `styleTagTransform` option can only be the path to the module
85+
86+
Migration:
87+
88+
Before:
89+
90+
**webpack.config.js**
91+
92+
```js
93+
module.exports = {
94+
module: {
95+
rules: [
96+
{
97+
test: /\.css$/i,
98+
use: [
99+
{
100+
loader: "style-loader",
101+
options: {
102+
injectType: "styleTag",
103+
styleTagTransform: function (css, style) {
104+
// Do something ...
105+
style.innerHTML = `${css}.modify{}\n`;
106+
107+
document.head.appendChild(style);
108+
},
109+
},
110+
},
111+
"css-loader",
112+
],
113+
},
114+
],
115+
},
116+
};
117+
```
118+
119+
After:
120+
121+
**style-tag-transform-function.js**
122+
123+
```js
124+
function styleTagTransform(css, style) {
125+
// Do something ...
126+
style.innerHTML = `${css}.modify{}\n`;
127+
128+
document.head.appendChild(style);
129+
}
130+
131+
module.exports = styleTagTransform;
132+
```
133+
134+
**webpack.config.js**
135+
136+
```js
137+
module.exports = {
138+
module: {
139+
rules: [
140+
{
141+
test: /\.css$/i,
142+
use: [
143+
{
144+
loader: "style-loader",
145+
options: {
146+
styleTagTransform: require.resolve("./style-tag-transform-function.js"),
147+
},
148+
},
149+
"css-loader",
150+
],
151+
},
152+
],
153+
},
154+
};
155+
```
156+
157+
### Bug Fixes
158+
159+
* css experiments logic ([#617](https://github.com/webpack-contrib/style-loader/issues/617)) ([8b9fc97](https://github.com/webpack-contrib/style-loader/commit/8b9fc976628341d3e33b77b5eb4b6ebad009fd19))
160+
5161
### [3.3.3](https://github.com/webpack-contrib/style-loader/compare/v3.3.2...v3.3.3) (2023-05-19)
6162

7163

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "style-loader",
3-
"version": "3.3.3",
3+
"version": "4.0.0",
44
"description": "style loader module for webpack",
55
"license": "MIT",
66
"repository": "webpack-contrib/style-loader",

0 commit comments

Comments
 (0)