Skip to content

Commit 7488602

Browse files
author
hzsrc
committed
2 parents 0f61498 + 41d1e23 commit 7488602

File tree

17 files changed

+8593
-7832
lines changed

17 files changed

+8593
-7832
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[Makefile]
12+
indent_style = tab
13+
14+
[*.md]
15+
indent_size = 4
16+
trim_trailing_whitespace = false

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v8.9.4
1+
v14.9.0

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
A Webpack plugin to optimize \ minimize CSS assets.
44

5+
> :warning: For webpack v5 or above please use [css-minimizer-webpack-plugin](https://github.com/webpack-contrib/css-minimizer-webpack-plugin) instead.
6+
57
## What does the plugin do?
68

79
It will search for CSS assets during the Webpack build and will optimize \ minimize the CSS (by default it uses [cssnano](http://github.com/ben-eb/cssnano) but a custom CSS processor can be specified).
@@ -58,3 +60,4 @@ module.exports = {
5860
## License
5961

6062
MIT (http://www.opensource.org/licenses/mit-license.php)
63+

package-lock.json

Lines changed: 8517 additions & 7735 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "optimize-css-assets-webpack-plugin",
3-
"version": "5.0.2",
3+
"version": "5.0.3",
44
"description": "A Webpack plugin to optimize \\ minimize CSS assets, with sorce map file name support",
55
"keywords": [
66
"CSS",
@@ -25,20 +25,20 @@
2525
]
2626
},
2727
"dependencies": {
28-
"cssnano": "^4.1.0",
28+
"cssnano": "^4.1.10",
2929
"last-call-webpack-plugin": "^3.0.0"
3030
},
3131
"devDependencies": {
32-
"babel-core": "^6.26.0",
33-
"babel-jest": "^22.1.0",
32+
"babel-core": "^6.26.3",
33+
"babel-jest": "^26.3.0",
3434
"babel-plugin-transform-object-rest-spread": "^6.26.0",
3535
"babel-polyfill": "^6.26.0",
36-
"babel-preset-env": "^1.6.1",
37-
"css-loader": "^0.28.9",
36+
"babel-preset-env": "^1.7.0",
37+
"css-loader": "^3.6.0",
3838
"extract-text-webpack-plugin": "next",
39-
"jest": "^22.1.4",
39+
"jest": "^26.4.2",
4040
"style-loader": "^0.20.1",
41-
"webpack": "^4.9.1"
41+
"webpack": "^4.44.1"
4242
},
4343
"peerDependencies": {
4444
"webpack": "^4.0.0"

test/__snapshots__/webpack-integration.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ p {
1717
"
1818
`;
1919

20-
exports[`Webpack Integration Tests only-assetNameRegExp-processed 2`] = `"a{color:#00f}body{color:red;margin:0}p{margin:1000px}"`;
20+
exports[`Webpack Integration Tests only-assetNameRegExp-processed 2`] = `"a{color:#00f}body{margin:0;color:red}p{margin:1000px}"`;
2121

2222
exports[`Webpack Integration Tests removes-duplicate-css 1`] = `"a{color:#00f}body{color:red}p{color:green}"`;
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
body {
2-
color: red;
3-
}
4-
a {
5-
color: blue;
6-
}
1+
body{color:red}a{color:blue}
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
body {
2-
margin: 0;
3-
color: red;
4-
}
5-
p {
6-
margin: 1000px;
7-
}
1+
body{margin:0;color:red}p{margin:1000px}
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
body {
2-
color: red;
3-
padding: 0;
4-
margin: 0;
5-
}
6-
p {
7-
padding: 500px;
8-
padding: 1000px;
9-
}
1+
body{color:red;padding:0;margin:0}p{padding:500px;padding:1000px}

test/cases/assetNameRegExp-no-source/webpack.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ module.exports = {
1010
use: ExtractTextPlugin.extract({
1111
fallback: { loader: 'style-loader' },
1212
use: {
13-
loader: 'css-loader',
14-
options: { minimize: true }
13+
loader: 'css-loader'
1514
}
1615
})
1716
},
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
body {
2-
color: red;
3-
}
4-
a {
5-
color: blue;
6-
}
1+
body{color:red}a{color:blue}
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
body {
2-
color: red;
3-
}
4-
p {
5-
color: green;
6-
}
1+
body{color:red}p{color:green}
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
import ExtractTextPlugin from 'extract-text-webpack-plugin';
2-
import OptimizeCssAssetsPlugin from '../../../src/';
1+
import ExtractTextPlugin from "extract-text-webpack-plugin";
2+
import OptimizeCssAssetsPlugin from "../../../src/";
33

44
module.exports = {
5-
entry: './index',
5+
entry: "./index",
66
module: {
77
rules: [
88
{
99
test: /\.css$/,
1010
use: ExtractTextPlugin.extract({
11-
fallback: { loader: 'style-loader' },
11+
fallback: { loader: "style-loader" },
1212
use: {
13-
loader: 'css-loader',
14-
options: { minimize: true }
13+
loader: "css-loader"
1514
}
1615
})
17-
},
18-
],
16+
}
17+
]
1918
},
20-
plugins: [
21-
new ExtractTextPlugin('file.css')
22-
],
19+
plugins: [new ExtractTextPlugin("file.css")]
2320
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a{color:#00f}body{color:red;margin:0}p{margin:1000px}
1+
a{color:#00f}body{margin:0;color:red}p{margin:1000px}
Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,38 @@
1-
import ExtractTextPlugin from 'extract-text-webpack-plugin';
2-
import OptimizeCssAssetsPlugin from '../../../src/';
1+
import ExtractTextPlugin from "extract-text-webpack-plugin";
2+
import OptimizeCssAssetsPlugin from "../../../src/";
33

4-
const notToProcess = new ExtractTextPlugin('as_is.css');
5-
const toProcess = new ExtractTextPlugin('optimize.css');
4+
const notToProcess = new ExtractTextPlugin("as_is.css");
5+
const toProcess = new ExtractTextPlugin("optimize.css");
66

77
module.exports = {
8-
entry: './index',
8+
entry: "./index",
99
module: {
1010
rules: [
1111
{
1212
test: /as-is\.css$/,
1313
use: notToProcess.extract({
14-
fallback: { loader: 'style-loader' },
14+
fallback: { loader: "style-loader" },
1515
use: {
16-
loader: 'css-loader',
17-
options: { minimize: false }
16+
loader: "css-loader"
1817
}
1918
})
2019
},
2120
{
2221
test: /optimize-me\.css$/,
2322
use: toProcess.extract({
24-
fallback: { loader: 'style-loader' },
23+
fallback: { loader: "style-loader" },
2524
use: {
26-
loader: 'css-loader',
27-
options: { minimize: false }
25+
loader: "css-loader"
2826
}
2927
})
3028
}
31-
],
29+
]
3230
},
3331
plugins: [
3432
notToProcess,
3533
toProcess,
3634
new OptimizeCssAssetsPlugin({
3735
assetNameRegExp: /optimize\.css/g
3836
})
39-
],
37+
]
4038
};
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
import ExtractTextPlugin from 'extract-text-webpack-plugin';
2-
import OptimizeCssAssetsPlugin from '../../../src/';
1+
import ExtractTextPlugin from "extract-text-webpack-plugin";
2+
import OptimizeCssAssetsPlugin from "../../../src/";
33

44
module.exports = {
5-
entry: './index',
5+
entry: "./index",
66
module: {
77
rules: [
88
{
99
test: /\.css$/,
1010
use: ExtractTextPlugin.extract({
11-
fallback: { loader: 'style-loader' },
11+
fallback: { loader: "style-loader" },
1212
use: {
13-
loader: 'css-loader',
14-
options: { minimize: true }
13+
loader: "css-loader"
1514
}
1615
})
17-
},
18-
],
16+
}
17+
]
1918
},
20-
plugins: [
21-
new ExtractTextPlugin('file.css'),
22-
new OptimizeCssAssetsPlugin()
23-
],
19+
plugins: [new ExtractTextPlugin("file.css"), new OptimizeCssAssetsPlugin()]
2420
};

test/util/helpers.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
1-
import fs from 'fs';
2-
import path from 'path';
3-
import ExtractTextPlugin from 'extract-text-webpack-plugin';
1+
import fs from "fs";
2+
import path from "path";
3+
import ExtractTextPlugin from "extract-text-webpack-plugin";
44

55
export function readFileOrEmpty(path) {
66
try {
7-
return fs.readFileSync(path, 'utf-8');
7+
return fs.readFileSync(path, "utf-8");
88
} catch (e) {
9-
return '';
9+
return "";
1010
}
1111
}
1212

1313
export const defaultConfig = {
14-
entry: './index',
14+
entry: "./index",
1515
module: {
1616
rules: [
1717
{
1818
test: /\.css$/,
1919
use: ExtractTextPlugin.extract({
20-
fallback: { loader: 'style-loader' },
20+
fallback: { loader: "style-loader" },
2121
use: {
22-
loader: 'css-loader',
23-
options: { minimize: true }
22+
loader: "css-loader"
2423
}
2524
})
26-
},
27-
],
25+
}
26+
]
2827
},
2928
plugins: [],
3029
context: __dirname,
3130
output: {
32-
filename: 'destination.js',
33-
path: path.resolve(__dirname, '../', 'js', 'default-exports')
31+
filename: "destination.js",
32+
path: path.resolve(__dirname, "../", "js", "default-exports")
3433
}
3534
};
3635

37-
export function checkForWebpackErrors({err, stats, done}) {
36+
export function checkForWebpackErrors({ err, stats, done }) {
3837
if (err) return done(err);
3938
if (stats.hasErrors()) return done(new Error(stats.toString()));
4039
}

0 commit comments

Comments
 (0)