Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

29 changes: 0 additions & 29 deletions .eslintrc.js

This file was deleted.

6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
loader: "style-loader",
options: {
injectType: "styleTag",
styleTagTransform: function (css, style) {
styleTagTransform (css, style) {
// Do something ...
style.innerHTML = `${css}.modify{}\n`;

Expand All @@ -50,7 +50,7 @@ After:

```js
function insert(css, style) {
var parent = options.target || document.head;
const parent = options.target || document.head;

parent.appendChild(element);
}
Expand Down Expand Up @@ -100,7 +100,7 @@ module.exports = {
loader: "style-loader",
options: {
injectType: "styleTag",
styleTagTransform: function (css, style) {
styleTagTransform (css, style) {
// Do something ...
style.innerHTML = `${css}.modify{}\n`;

Expand Down
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,13 @@ Insert styles at top of `head` tag:

**insert-function.js**

<!-- eslint-disable -->

```js
function insertAtTop(element) {
var parent = document.querySelector("head");
// eslint-disable-next-line no-underscore-dangle
var lastInsertedElement = window._lastElementInsertedByStyleLoader;
const parent = document.querySelector("head");

const lastInsertedElement = window._lastElementInsertedByStyleLoader;

if (!lastInsertedElement) {
parent.insertBefore(element, parent.firstChild);
Expand All @@ -567,7 +569,6 @@ function insertAtTop(element) {
parent.appendChild(element);
}

// eslint-disable-next-line no-underscore-dangle
window._lastElementInsertedByStyleLoader = element;
}

Expand Down Expand Up @@ -603,7 +604,7 @@ You can pass any parameters to `style.use(options)` and this value will be passe

```js
function insertIntoTarget(element, options) {
var parent = options.target || document.head;
const parent = options.target || document.head;

parent.appendChild(element);
}
Expand Down Expand Up @@ -844,6 +845,7 @@ For `development` mode (including `webpack-dev-server`), you can use `style-load

```js
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

const devMode = process.env.NODE_ENV !== "production";

module.exports = {
Expand All @@ -860,7 +862,7 @@ module.exports = {
},
],
},
plugins: [].concat(devMode ? [] : [new MiniCssExtractPlugin()]),
plugins: [devMode ? [] : [new MiniCssExtractPlugin()]].flat(),
};
```

Expand Down Expand Up @@ -891,7 +893,7 @@ module.exports = {
**index.js**

```js
import { fooBaz, bar, "my-class" as myClass } from "./styles.css";
import { bar, fooBaz, "my-class" as myClass } from "./styles.css";

console.log(fooBaz, bar, myClass);
```
Expand Down Expand Up @@ -1071,10 +1073,12 @@ Insert styles at top of `head` tag.

**insert-function.js**

<!-- eslint-disable -->

```js
function insertAtTop(element) {
var parent = document.querySelector("head");
var lastInsertedElement = window._lastElementInsertedByStyleLoader;
const parent = document.querySelector("head");
const lastInsertedElement = window._lastElementInsertedByStyleLoader;

if (!lastInsertedElement) {
parent.insertBefore(element, parent.firstChild);
Expand Down Expand Up @@ -1119,6 +1123,8 @@ Inserts styles before `#id` element.

**insert-function.js**

<!-- eslint-disable -->

```js
function insertBeforeAt(element) {
const parent = document.querySelector("head");
Expand Down Expand Up @@ -1171,7 +1177,7 @@ You can define custom target for your styles when using the `lazyStyleTag` type.

```js
function insertIntoTarget(element, options) {
var parent = options.target || document.head;
const parent = options.target || document.head;

parent.appendChild(element);
}
Expand Down
8 changes: 8 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from "eslint/config";
import configs from "eslint-config-webpack/configs.js";

export default defineConfig([
{
extends: [configs["recommended-dirty"]],
},
]);
Loading
Loading