Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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.

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

This file was deleted.

166 changes: 57 additions & 109 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,11 @@ module.exports = {
test: /\.style.js$/,
use: [
"style-loader",
{
loader: "css-loader",
},
{ loader: "css-loader" },
{
loader: "postcss-loader",
options: {
postcssOptions: {
parser: "postcss-js",
},
postcssOptions: { parser: "postcss-js" },
execute: true,
},
},
Expand All @@ -195,8 +191,8 @@ See the file [`./src/config.d.ts`](./src/config.d.ts).
Type:

```ts
import type { Config as PostCSSConfig } from "postcss-load-config";
import type { LoaderContext } from "webpack";
import { type Config as PostCSSConfig } from "postcss-load-config";
import { type LoaderContext } from "webpack";

type PostCSSLoaderContext = LoaderContext<PostCSSConfig>;

Expand Down Expand Up @@ -270,10 +266,7 @@ module.exports = {
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: {
"postcss-import": {},
"postcss-short": { prefix: "x" },
},
plugins: { "postcss-import": {}, "postcss-short": { prefix: "x" } },
},
},
},
Expand All @@ -286,6 +279,8 @@ Setup `syntax`:

**webpack.config.js**

<!-- eslint-skip -->

```js
module.exports = {
module: {
Expand All @@ -311,6 +306,8 @@ Setup `parser`:

**webpack.config.js**

<!-- eslint-skip -->

```js
module.exports = {
module: {
Expand Down Expand Up @@ -338,6 +335,8 @@ Setup `stringifier`:

**webpack.config.js**

<!-- eslint-skip -->

```js
const Midas = require("midas");
const midas = new Midas();
Expand Down Expand Up @@ -528,12 +527,7 @@ module.exports = {
test: /\.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 1,
},
},
{ loader: "css-loader", options: { importLoaders: 1 } },
"postcss-loader",
],
},
Expand All @@ -555,11 +549,7 @@ module.exports = {
{
test: /\.css$/i,
loader: "postcss-loader",
options: {
postcssOptions: {
config: false,
},
},
options: { postcssOptions: { config: false } },
},
],
},
Expand All @@ -573,7 +563,7 @@ Allows to specify the path to the config file.
**webpack.config.js**

```js
const path = require("path");
const path = require("node:path");

module.exports = {
module: {
Expand Down Expand Up @@ -738,17 +728,10 @@ module.exports = {
test: /\.sss$/i,
use: [
"style-loader",
{
loader: "css-loader",
options: { importLoaders: 1 },
},
{ loader: "css-loader", options: { importLoaders: 1 } },
{
loader: "postcss-loader",
options: {
postcssOptions: {
parser: "sugarss",
},
},
options: { postcssOptions: { parser: "sugarss" } },
},
],
},
Expand Down Expand Up @@ -777,10 +760,7 @@ module.exports = {
test: /\.css$/i,
use: [
"style-loader",
{
loader: "css-loader",
options: { importLoaders: 1 },
},
{ loader: "css-loader", options: { importLoaders: 1 } },
{
loader: "postcss-loader",
options: {
Expand Down Expand Up @@ -825,10 +805,7 @@ module.exports = {
test: /\.css$/i,
use: [
"style-loader",
{
loader: "css-loader",
options: { importLoaders: 1 },
},
{ loader: "css-loader", options: { importLoaders: 1 } },
{
loader: "postcss-loader",
options: {
Expand Down Expand Up @@ -870,10 +847,7 @@ module.exports = {
"style-loader",
{
loader: "css-loader",
options: {
modules: true,
importLoaders: 1,
},
options: { modules: true, importLoaders: 1 },
},
"postcss-loader",
],
Expand Down Expand Up @@ -905,18 +879,11 @@ module.exports = {
test: /\.style.js$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 2,
},
},
{ loader: "css-loader", options: { importLoaders: 2 } },
{
loader: "postcss-loader",
options: {
postcssOptions: {
parser: "postcss-js",
},
postcssOptions: { parser: "postcss-js" },
execute: true,
},
},
Expand All @@ -934,13 +901,7 @@ As result you will be able to write styles in the following way:
import colors from "./styles/colors";

export default {
".menu": {
color: colors.main,
height: 25,
"&_link": {
color: "white",
},
},
".menu": { color: colors.main, height: 25, "&_link": { color: "white" } },
};
```

Expand Down Expand Up @@ -1001,18 +962,16 @@ The message should contain the following fields:
**webpack.config.js**

```js
const postcssCustomPlugin = (opts = {}) => {
return {
postcssPlugin: "postcss-custom-plugin",
Once: (root, { result }) => {
result.messages.push({
type: "asset",
file: "sprite.svg",
content: "<svg>...</svg>",
});
},
};
};
const postcssCustomPlugin = (opts = {}) => ({
postcssPlugin: "postcss-custom-plugin",
Once: (root, { result }) => {
result.messages.push({
type: "asset",
file: "sprite.svg",
content: "<svg>...</svg>",
});
},
});

module.exports = {
module: {
Expand All @@ -1024,11 +983,7 @@ module.exports = {
"css-loader",
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [postcssCustomPlugin()],
},
},
options: { postcssOptions: { plugins: [postcssCustomPlugin()] } },
},
],
},
Expand All @@ -1055,19 +1010,17 @@ The message should contain the following fields:
**webpack.config.js**

```js
const path = require("path");

const postcssCustomPlugin = (opts = {}) => {
return {
postcssPlugin: "postcss-custom-plugin",
Once: (root, { result }) => {
result.messages.push({
type: "dependency",
file: path.resolve(__dirname, "path", "to", "file"),
});
},
};
};
const path = require("node:path");

const postcssCustomPlugin = (opts = {}) => ({
postcssPlugin: "postcss-custom-plugin",
Once: (root, { result }) => {
result.messages.push({
type: "dependency",
file: path.resolve(__dirname, "path", "to", "file"),
});
},
});

module.exports = {
module: {
Expand All @@ -1079,11 +1032,7 @@ module.exports = {
"css-loader",
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [postcssCustomPlugin()],
},
},
options: { postcssOptions: { plugins: [postcssCustomPlugin()] } },
},
],
},
Expand All @@ -1099,7 +1048,7 @@ module.exports = {
**webpack.config.js**

```js
const path = require("path");
const path = require("node:path");

module.exports = {
module: {
Expand Down Expand Up @@ -1145,20 +1094,19 @@ module.exports = (api) => ({
Register a file dependency using `loaderContext.addDependency`:

```js
const path = require("path");

const postcssCustomPlugin = (opts = {}) => {
return {
postcssPlugin: "postcss-custom-plugin",
Once: (root, { result }) => {
opts.loaderContext.addDependency(
path.resolve(__dirname, "path", "to", "file"),
);
},
};
};
const path = require("node:path");

const postcssCustomPlugin = (opts = {}) => ({
postcssPlugin: "postcss-custom-plugin",
Once: (root, { result }) => {
opts.loaderContext.addDependency(
path.resolve(__dirname, "path", "to", "file"),
);
},
});

postcssCustomPlugin.postcss = true;

module.exports = postcssCustomPlugin;
```

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"]],
},
]);
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
testTimeout: 10000,
transform: {
"\\.[mc]?tsx?$": ["ts-jest", { rootDir: ".", esModuleInterop: true }],
"\\.[mc]?jsx?$": "babel-jest",
Expand Down
Loading
Loading