@nitro/webpack 11.0.6 → 11.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitro/webpack",
3
- "version": "11.0.6",
3
+ "version": "11.0.7",
4
4
  "description": "nitro webpack",
5
5
  "license": "MIT",
6
6
  "author": "The Nitro Team",
@@ -22,7 +22,7 @@
22
22
  "nitro"
23
23
  ],
24
24
  "peerDependencies": {
25
- "@nitro/app": ">=11.0.6",
25
+ "@nitro/app": ">=11.0.7",
26
26
  "webpack": "^5"
27
27
  },
28
28
  "dependencies": {
@@ -32,21 +32,23 @@
32
32
  "@babel/plugin-proposal-decorators": "7.29.0",
33
33
  "@babel/plugin-transform-class-properties": "7.28.6",
34
34
  "autoprefixer": "10.4.27",
35
- "babel-loader": "10.0.0",
35
+ "babel-loader": "10.1.1",
36
36
  "case-sensitive-paths-webpack-plugin": "2.4.0",
37
37
  "css-loader": "7.1.4",
38
- "cssnano": "7.1.2",
38
+ "css-minimizer-webpack-plugin": "8.0.0",
39
+ "cssnano": "7.1.3",
39
40
  "config": "4.4.1",
40
41
  "image-minimizer-webpack-plugin": "5.0.0",
41
42
  "fork-ts-checker-webpack-plugin": "9.1.0",
42
43
  "handlebars-loader": "1.7.3",
43
44
  "imagemin": "9.0.1",
44
- "mini-css-extract-plugin": "2.10.0",
45
+ "mini-css-extract-plugin": "2.10.1",
45
46
  "postcss": "8.5.8",
46
47
  "postcss-loader": "8.2.1",
47
48
  "resolve-url-loader": "5.0.0",
48
- "sass": "1.97.3",
49
+ "sass": "1.98.0",
49
50
  "sass-loader": "16.0.7",
51
+ "terser-webpack-plugin": "5.4.0",
50
52
  "thread-loader": "4.0.4",
51
53
  "ts-loader": "9.5.4",
52
54
  "typescript": "5.9.3",
package/readme.md CHANGED
@@ -8,7 +8,7 @@ Configurable and easy to use webpack 5 config for nitro projects.
8
8
 
9
9
  ## Usage
10
10
 
11
- ```
11
+ ```js
12
12
  const options = {
13
13
  rules: {
14
14
  script: true,
@@ -3,6 +3,7 @@ const fs = require('fs');
3
3
  const webpack = require('webpack');
4
4
  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
5
5
  const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
6
+ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
6
7
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
7
8
  const TerserPlugin = require('terser-webpack-plugin');
8
9
  const WebpackBar = require('webpackbar');
@@ -17,9 +18,11 @@ const bannerData = {
17
18
  pkg: require(`${appDirectory}/package.json`),
18
19
  };
19
20
 
20
- const banner = `${bannerData.pkg.name}
21
- @version v${bannerData.pkg.version}
22
- @date ${bannerData.date}`;
21
+ const bannerContent = `/**
22
+ * ${bannerData.pkg.name}
23
+ * @version v${bannerData.pkg.version}
24
+ * @date ${bannerData.date}
25
+ */`;
23
26
 
24
27
  module.exports = (options = { rules: {}, features: {} }) => {
25
28
  const imageMinimizerPlugins = [];
@@ -68,7 +71,48 @@ module.exports = (options = { rules: {}, features: {} }) => {
68
71
  );
69
72
  }
70
73
 
71
- const minimizerPlugins = [new TerserPlugin({ extractComments: false })];
74
+ const escapedPackageName = bannerData.pkg.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
75
+ const packageNameRegExp = new RegExp(escapedPackageName);
76
+
77
+ const minimizerPlugins = [
78
+ new TerserPlugin({
79
+ extractComments: {
80
+ condition: /@license|@preserve|^!/i,
81
+ filename: (file) => {
82
+ const entryName = file.basename
83
+ .replace(/\.min/, '')
84
+ .replace(/\.js$/, '');
85
+
86
+ return `${entryName}.license.txt`;
87
+ },
88
+ banner: (licenseFile) => `See ../${licenseFile} for license information`,
89
+ },
90
+ terserOptions: {
91
+ format: {
92
+ comments: packageNameRegExp,
93
+ },
94
+ // compress: true,
95
+ // mangle: true,
96
+ },
97
+ parallel: true,
98
+ }),
99
+ new CssMinimizerPlugin({
100
+ parallel: false,
101
+ minimizerOptions: {
102
+ preset: [
103
+ 'default',
104
+ {
105
+ discardComments: {
106
+ remove: (comment) => {
107
+ return !packageNameRegExp.test(comment);
108
+ },
109
+ },
110
+ },
111
+ ],
112
+ },
113
+ }),
114
+ ];
115
+
72
116
  if (!(options.features.imageMinimizer === false || imageMinimizerPlugins.length === 0)) {
73
117
  minimizerPlugins.push(
74
118
  new ImageMinimizerPlugin({
@@ -298,7 +342,11 @@ module.exports = (options = { rules: {}, features: {} }) => {
298
342
 
299
343
  // feature banner (enabled by default)
300
344
  if (!options.features.banner === false) {
301
- webpackConfig.plugins.push(new webpack.BannerPlugin({ banner, entryOnly: true }));
345
+ webpackConfig.plugins.push(new webpack.BannerPlugin({
346
+ banner: bannerContent.trim(),
347
+ raw: true,
348
+ entryOnly: true,
349
+ }));
302
350
  }
303
351
 
304
352
  // feature bundle analyzer