Skip to content

Commit 8200874

Browse files
committed
feature: cloudcmd: optimize-css-assets-webpack-plugin -> css-minimizer-webpack-plugin
1 parent 4b8568b commit 8200874

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

.webpack/css.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
'use strict';
22

3-
const {env} = require('node:process');
4-
5-
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
63
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
74

8-
const isDev = env.NODE_ENV === 'development';
9-
105
const clean = (a) => a.filter(Boolean);
116

127
const plugins = clean([
138
new MiniCssExtractPlugin({
149
filename: '[name].css',
1510
}),
16-
!isDev && new OptimizeCssAssetsPlugin(),
1711
]);
1812

1913
const rules = [{

.webpack/js.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const {
1313
} = require('webpack');
1414

1515
const WebpackBar = require('webpackbar');
16+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
1617

1718
const modules = './modules';
1819
const dirModules = './client/modules';
@@ -105,6 +106,18 @@ module.exports = {
105106
devtool,
106107
optimization: {
107108
splitChunks,
109+
minimize: true,
110+
minimizer: [
111+
new CssMinimizerPlugin({
112+
minimizerOptions: {
113+
preset: ['default', {
114+
discardComments: {
115+
removeAll: true,
116+
},
117+
}],
118+
},
119+
}),
120+
],
108121
},
109122
entry: {
110123
'themes/dark': `${dirThemes}/dark.css`,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
"clean-css-loader": "^4.2.1",
169169
"codegen.macro": "^4.0.0",
170170
"css-loader": "^7.1.2",
171+
"css-minimizer-webpack-plugin": "^7.0.2",
171172
"css-modules-require-hook": "^4.2.3",
172173
"domtokenlist-shim": "^1.2.0",
173174
"emitify": "^4.0.1",
@@ -192,7 +193,6 @@
192193
"morgan": "^1.6.1",
193194
"multi-rename": "^2.0.0",
194195
"nodemon": "^3.0.1",
195-
"optimize-css-assets-webpack-plugin": "^6.0.1",
196196
"path-browserify": "^1.0.1",
197197
"philip": "^3.0.0",
198198
"place": "^1.1.4",

server/columns.spec.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import {dirname} from 'node:path';
1+
import {join, dirname} from 'node:path';
22
import {fileURLToPath} from 'node:url';
33
import fs from 'node:fs';
44
import test from 'supertape';
55
import {getColumns, isDev} from './columns.mjs';
66

77
const __filename = fileURLToPath(import.meta.url);
88
const __dirname = dirname(__filename);
9+
const distDir = join(__dirname, '..', 'dist-dev');
910

1011
test('columns: prod', (t) => {
1112
const columns = getColumns({
@@ -21,7 +22,7 @@ test('columns: dev', (t) => {
2122
isDev: true,
2223
});
2324

24-
const css = fs.readFileSync(`${__dirname}/../css/columns/name-size-date.css`, 'utf8');
25+
const css = fs.readFileSync(`${distDir}/columns/name-size-date.css`, 'utf8');
2526

2627
t.match(columns['name-size-date'], css);
2728
t.end();
@@ -32,7 +33,7 @@ test('columns: no args', (t) => {
3233
isDev(true);
3334
const columns = getColumns();
3435

35-
const css = fs.readFileSync(`${__dirname}/../css/columns/name-size-date.css`, 'utf8');
36+
const css = fs.readFileSync(`${distDir}/columns/name-size-date.css`, 'utf8');
3637
isDev(currentIsDev);
3738

3839
t.match(columns['name-size-date'], css);

server/themes.spec.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import {dirname} from 'node:path';
1+
import {dirname, join} from 'node:path';
22
import {fileURLToPath} from 'node:url';
33
import fs from 'node:fs';
44
import test from 'supertape';
55
import {getThemes, isDev} from './theme.mjs';
66

77
const __filename = fileURLToPath(import.meta.url);
88
const __dirname = dirname(__filename);
9+
const distDir = join(__dirname, '..', 'dist-dev');
910

1011
test('themes: dev', (t) => {
1112
const themes = getThemes({
1213
isDev: true,
1314
});
1415

15-
const css = fs.readFileSync(`${__dirname}/../css/themes/dark.css`, 'utf8');
16+
const css = fs.readFileSync(`${distDir}/themes/dark.css`, 'utf8');
1617
const result = themes.dark.includes(css);
1718

1819
t.ok(result);
@@ -24,7 +25,7 @@ test('themes: no args', (t) => {
2425
isDev(true);
2526
const themes = getThemes();
2627

27-
const css = fs.readFileSync(`${__dirname}/../css/themes/light.css`, 'utf8');
28+
const css = fs.readFileSync(`${distDir}/themes/light.css`, 'utf8');
2829
isDev(currentIsDev);
2930

3031
t.match(themes.light, css);

0 commit comments

Comments
 (0)