Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong import name #1015

Merged
merged 1 commit into from Nov 12, 2022
Merged
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
14 changes: 7 additions & 7 deletions docs/plugins/webpack.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ npm i purgecss-webpack-plugin -D
const path = require("path");
const glob = require("glob");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { PurgecssPlugin } = require("purgecss-webpack-plugin");
const { PurgeCSSPlugin } = require("purgecss-webpack-plugin");

const PATHS = {
src: path.join(__dirname, "src"),
Expand Down Expand Up @@ -78,7 +78,7 @@ module.exports = {
new MiniCssExtractPlugin({
filename: "[name].css",
}),
new PurgecssPlugin({
new PurgeCSSPlugin({
paths: glob.sync(`${PATHS.src}/**/*`, { nodir: true }),
}),
],
Expand All @@ -90,7 +90,7 @@ module.exports = {
If you need multiple paths use the npm package `glob-all` instead of `glob`, then you can use this syntax:

```js
new PurgecssPlugin({
new PurgeCSSPlugin({
paths: glob.sync([
// ...
])
Expand All @@ -110,22 +110,22 @@ With the webpack plugin, you can specify the content that should be analyzed by
> You likely need to pass `{ noDir: true }` as an option to `glob.sync()` as `glob.sync` is matching a dir which the plugin can't operate on.

```js
const { PurgecssPlugin } = require("purgecss-webpack-plugin");
const { PurgeCSSPlugin } = require("purgecss-webpack-plugin");
const glob = require("glob");
const PATHS = {
src: path.join(__dirname, "src"),
};

// In the webpack configuration
new PurgecssPlugin({
new PurgeCSSPlugin({
paths: glob.sync(`${PATHS.src}/**/*`, { nodir: true }),
});
```

If you want to regenerate the list of paths on every compilation (e.g. when using `--watch`), then you can also pass a function to the `paths` option as in the following example:

```js
new PurgecssPlugin({
new PurgeCSSPlugin({
paths: () => glob.sync(`${PATHS.src}/**/*`, { nodir: true }),
});
```
Expand All @@ -135,7 +135,7 @@ new PurgecssPlugin({
You can specify chunk names to the purgecss-webpack-plugin with the option `only`:

```js
new PurgecssPlugin({
new PurgeCSSPlugin({
paths: glob.sync(`${PATHS.src}/**/*`, { nodir: true }),
only: ["bundle", "vendor"],
});
Expand Down