From 7c4153e2eb88ccdbcd9776efbdfc42a34c2d257d Mon Sep 17 00:00:00 2001 From: Jan Naahs Date: Sun, 22 Nov 2020 19:41:34 +0100 Subject: [PATCH] purge css only in production and adjust webpack.config.js --- package-lock.json | 63 ++++++++++++++++++++++++++++++++++++++++------ package.json | 3 ++- tailwind.config.js | 8 +++++- webpack.config.js | 10 ++++---- 4 files changed, 69 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index bc5691d..1364ef2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1635,11 +1635,6 @@ "postcss-value-parser": "^4.1.0" }, "dependencies": { - "caniuse-lite": { - "version": "1.0.30001117", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001117.tgz", - "integrity": "sha512-4tY0Fatzdx59kYjQs+bNxUwZB03ZEBgVmJ1UkFPz/Q8OLiUUbjct2EdpnXj0fvFTPej2EkbPIG0w8BWsjAyk1Q==" - }, "postcss-value-parser": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.1.0.tgz", @@ -2116,9 +2111,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001079", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001079.tgz", - "integrity": "sha512-2KaYheg0iOY+CMmDuAB3DHehrXhhb4OZU4KBVGDr/YKyYAcpudaiUQ9PJ9rxrPlKEoJ3ATasQ5AN48MqpwS43Q==" + "version": "1.0.30001159", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001159.tgz", + "integrity": "sha512-w9Ph56jOsS8RL20K9cLND3u/+5WASWdhC/PPrf+V3/HsM3uHOavWOR1Xzakbv4Puo/srmPHudkmCRWM7Aq+/UA==" }, "caseless": { "version": "0.12.0", @@ -2557,6 +2552,58 @@ "sha.js": "^2.4.8" } }, + "cross-env": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.2.tgz", + "integrity": "sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.1" + }, + "dependencies": { + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, "cross-spawn": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-3.0.1.tgz", diff --git a/package.json b/package.json index 3beaf56..00828b7 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "watch-poll": "npm run watch -- --watch-poll", "build": "npm run production", "prod": "npm run production", - "production": "webpack --config=webpack.config.js --mode=production --hide-modules --progress", + "production": "cross-env NODE_ENV=production webpack --config=webpack.config.js --mode=production --hide-modules --progress", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { @@ -30,6 +30,7 @@ "autoprefixer": "^9.8.6", "babel-loader": "^8.0.6", "classnames": "^2.2.6", + "cross-env": "^7.0.2", "css-loader": "^2.1.0", "file-loader": "^3.0.1", "locks": "^0.2.2", diff --git a/tailwind.config.js b/tailwind.config.js index f1a8025..02a3752 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -3,7 +3,13 @@ module.exports = { removeDeprecatedGapUtilities: true, purgeLayersByDefault: true, }, - purge: [], + purge: { + mode: 'all', + content: [ + './ui/**/*.jsx', + './ui/**/*.html', + ] +}, theme: { extend: { width: { diff --git a/webpack.config.js b/webpack.config.js index 66371f0..7e451a9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,6 @@ const path = require('path'); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); -var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); +const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); /** * TODO remove when webpack fixed this error: * Links to this error: @@ -15,7 +15,7 @@ var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries"); module.exports = (env, argv) => { - const isProduction = argv.mode == 'production'; + const isProduction = argv.mode === 'production'; return { entry: { @@ -33,7 +33,7 @@ module.exports = (env, argv) => { }, extensions: ['.js', '.json', '.jsx'] }, - devtool: (isProduction) ? "none" : "source-map", + devtool: isProduction ? "none" : "source-map", module: { rules: [ { @@ -85,7 +85,7 @@ module.exports = (env, argv) => { }, { test: /(\.(png|jpe?g|gif)$|^((?!font).)*\.svg$)/, - loaders: [ + use: [ { loader: "file-loader", options: { @@ -107,7 +107,7 @@ module.exports = (env, argv) => { }, { test: /(\.(woff2?|ttf|eot|otf)$|font.*\.svg$)/, - loaders: [ + use: [ { loader: "file-loader", options: {