@nitro-web/webpack 0.0.23 → 0.0.25

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-web/webpack",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "repository": "github:boycce/nitro-web",
5
5
  "homepage": "https://boycce.github.io/nitro-web/",
6
6
  "main": "./webpack.config.js",
@@ -78,6 +78,6 @@
78
78
  "extends": "../core/.eslintrc.json"
79
79
  },
80
80
  "engines": {
81
- "node": ">=18"
81
+ "node": ">=18 <21"
82
82
  }
83
83
  }
package/webpack.config.js CHANGED
@@ -21,6 +21,7 @@ import { getDirectories } from 'nitro-web/util'
21
21
  const _require = createRequire(import.meta.url)
22
22
  const pick = (object, list) => list.reduce((o, e) => ((o[e] = object[e]), o), {})
23
23
  const isBuild = process.env.NODE_ENV == 'production'
24
+ const nitroVersion = _require('./package.json').version
24
25
 
25
26
  // axiosRetry(axios, {
26
27
  // retries: 10,
@@ -274,8 +275,9 @@ export const getConfig = (config) => {
274
275
  }),
275
276
  new webpack.DefinePlugin({
276
277
  ISDEMO: !!process.env.isDemo,
277
- INJECTED: JSON.stringify({
278
+ INJECTED_CONFIG: JSON.stringify({
278
279
  ...pick(config, config.inject ? config.inject.split(' ') : []),
280
+ version: process.env.isDemo ? nitroVersion : config.version,
279
281
  }),
280
282
  }),
281
283
  new ESLintPlugin({
@@ -336,19 +338,21 @@ class InterpolateHtmlPlugin {
336
338
 
337
339
  function getPublicPath(env, homepage, publicPath) {
338
340
  /**
339
- * Returns public path used for webapck (we can't use relative paths)
341
+ * Returns public path used for webpack, used in the relative asset paths
340
342
  * @param {string} env - 'development', 'staging', 'production'
341
- * @param {string} publicPath - proces.env.publicPath
342
343
  * @param {string} homepage - package.json homepage
344
+ * @param {string} <publicPath> - process.env.publicPath
343
345
  */
344
346
  if (publicPath) {
345
347
  const publicPathObj = new URL(publicPath, 'https://domain.com')
348
+ if (env !== 'development') console.info(`Public path: ${publicPathObj.pathname}`)
346
349
  return publicPathObj.pathname
347
350
 
348
351
  } else if (homepage) {
349
352
  const homepageObj = new URL(homepage, 'https://domain.com')
350
- if (env === 'development') return '/'
351
- else return homepageObj.pathname
353
+ if (env !== 'development') console.info(`Public path, from package homepage: ${homepageObj.pathname}`)
354
+ if (env !== 'development') return homepageObj.pathname
355
+ else return '/'
352
356
 
353
357
  } else {
354
358
  return '/'