Skip to content

Commit

Permalink
attempt to use purgecss again
Browse files Browse the repository at this point in the history
modules (import) vs require stuff is so confusing and documentation so
poor, no idea what i am doing or of this is the right direction
  • Loading branch information
alcohol committed Dec 24, 2024
1 parent 523453d commit 456349b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"bootstrap": "^5.3.3",
"date-fns": "^4.1.0",
"eslint-webpack-plugin": "^4.2.0",
"glob": "^11.0.0",
"husky": "^9.1.7",
"lint-staged": "^15.2.11",
"prettier": "^3.4.2",
Expand Down
2 changes: 1 addition & 1 deletion views/build/style.css

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Encore from "@symfony/webpack-encore";
import { PurgeCSSPlugin } from "purgecss-webpack-plugin";
import { glob } from "glob";

Encore.addEntry("app", "./views/assets/js/app.js")
.addStyleEntry("style", "./views/assets/css/style.scss")
Expand All @@ -8,7 +10,11 @@ Encore.addEntry("app", "./views/assets/js/app.js")
.enableSourceMaps(!Encore.isProduction())
.setOutputPath("views/build/")
.setPublicPath("/build")
;
.addPlugin(
new PurgeCSSPlugin({
paths: () => glob.sync([`views/*.html.twig`, `views/assets/js/**/*.js`], { nodir: true }),
}),
);

const config = Encore.getWebpackConfig();

Expand All @@ -19,4 +25,4 @@ config.output.environment.arrowFunction = false;
config.output.environment.const = false;
config.output.environment.destructuring = false;

export { config as default }
export { config as default };

0 comments on commit 456349b

Please sign in to comment.