@nitro/webpack 11.0.4 → 11.0.6

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.4",
3
+ "version": "11.0.6",
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.4",
25
+ "@nitro/app": ">=11.0.6",
26
26
  "webpack": "^5"
27
27
  },
28
28
  "dependencies": {
@@ -36,12 +36,13 @@
36
36
  "case-sensitive-paths-webpack-plugin": "2.4.0",
37
37
  "css-loader": "7.1.4",
38
38
  "cssnano": "7.1.2",
39
- "image-minimizer-webpack-plugin": "4.1.4",
39
+ "config": "4.4.1",
40
+ "image-minimizer-webpack-plugin": "5.0.0",
40
41
  "fork-ts-checker-webpack-plugin": "9.1.0",
41
42
  "handlebars-loader": "1.7.3",
42
43
  "imagemin": "9.0.1",
43
44
  "mini-css-extract-plugin": "2.10.0",
44
- "postcss": "8.5.6",
45
+ "postcss": "8.5.8",
45
46
  "postcss-loader": "8.2.1",
46
47
  "resolve-url-loader": "5.0.0",
47
48
  "sass": "1.97.3",
@@ -62,7 +63,7 @@
62
63
  "@merkle-open/eslint-config": "4.0.1",
63
64
  "eslint": "8.57.1",
64
65
  "eslint-plugin-import": "2.32.0",
65
- "webpack": "5.105.3"
66
+ "webpack": "5.105.4"
66
67
  },
67
68
  "publishConfig": {
68
69
  "access": "public"
@@ -1,5 +1,6 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
+ const config = require('config');
3
4
  const webpack = require('webpack');
4
5
  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
5
6
  const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
@@ -7,7 +8,8 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
7
8
  const utils = require('../lib/utils');
8
9
  const webpackRules = require('../lib/webpack-rules');
9
10
 
10
- const hotMiddlewareScript = 'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true';
11
+ const hmrPort = config.get('server.hmrPort');
12
+ const hotMiddlewareScript = `webpack-hot-middleware/client?path=http://localhost:${hmrPort}/__webpack_hmr&timeout=20000&reload=true`;
11
13
  const appDirectory = fs.realpathSync(process.cwd());
12
14
 
13
15
  module.exports = (options = { rules: {}, features: {} }) => {
@@ -16,8 +18,8 @@ module.exports = (options = { rules: {}, features: {} }) => {
16
18
  devtool: 'source-map',
17
19
  context: appDirectory,
18
20
  entry: {
19
- ui: ['./src/ui', hotMiddlewareScript],
20
- proto: ['./src/proto', hotMiddlewareScript],
21
+ ui: [hotMiddlewareScript, './src/ui'],
22
+ proto: [hotMiddlewareScript, './src/proto'],
21
23
  },
22
24
  output: {
23
25
  path: path.resolve(appDirectory, 'public', 'assets'),
@@ -87,7 +89,7 @@ module.exports = (options = { rules: {}, features: {} }) => {
87
89
  const theme = options.features.theme ? options.features.theme : false;
88
90
 
89
91
  if (theme) {
90
- webpackConfig.entry.ui = [`./src/ui.${theme}`, hotMiddlewareScript];
92
+ webpackConfig.entry.ui = [hotMiddlewareScript, `./src/ui.${theme}`];
91
93
  webpackConfig.output.path = path.resolve(webpackConfig.output.path, theme);
92
94
  webpackConfig.output.publicPath = `${webpackConfig.output.publicPath}${theme}/`;
93
95
  }
@@ -210,7 +212,7 @@ module.exports = (options = { rules: {}, features: {} }) => {
210
212
  // images
211
213
  if (options.rules.image) {
212
214
  const imageRule = {
213
- test: /\.(png|jpg|gif|svg)$/,
215
+ test: /\.(png|jpe?g|gif|svg|webp)$/i,
214
216
  type: 'asset',
215
217
  parser: {
216
218
  dataUrlCondition: {
@@ -218,7 +220,11 @@ module.exports = (options = { rules: {}, features: {} }) => {
218
220
  },
219
221
  },
220
222
  generator: {
221
- filename: 'media/[ext]/[name]-[contenthash:7][ext]',
223
+ filename: (pathData) => {
224
+ const match = pathData.filename.match(/\.([^.?#]+)(?:[?#].*)?$/);
225
+ const extNoDot = match ? match[1] : 'asset';
226
+ return `media/${extNoDot}/[name]-[contenthash:7][ext]`;
227
+ },
222
228
  },
223
229
  };
224
230
  webpackConfig.module.rules.push(utils.getEnrichedConfig(imageRule, options.rules.image));
@@ -277,7 +277,7 @@ module.exports = (options = { rules: {}, features: {} }) => {
277
277
  // images
278
278
  if (options.rules.image) {
279
279
  const imageRule = {
280
- test: /\.(png|jpg|gif|svg)$/,
280
+ test: /\.(png|jpe?g|gif|svg|webp)$/i,
281
281
  type: 'asset',
282
282
  parser: {
283
283
  dataUrlCondition: {
@@ -285,7 +285,11 @@ module.exports = (options = { rules: {}, features: {} }) => {
285
285
  },
286
286
  },
287
287
  generator: {
288
- filename: 'media/[ext]/[name]-[contenthash:7][ext]',
288
+ filename: (pathData) => {
289
+ const match = pathData.filename.match(/\.([^.?#]+)(?:[?#].*)?$/);
290
+ const extNoDot = match ? match[1] : 'asset';
291
+ return `media/${extNoDot}/[name]-[contenthash:7][ext]`;
292
+ },
289
293
  },
290
294
  };
291
295