@nitro-web/webpack 0.0.25 → 0.0.27

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.
Files changed (2) hide show
  1. package/package.json +1 -2
  2. package/webpack.config.js +15 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitro-web/webpack",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "repository": "github:boycce/nitro-web",
5
5
  "homepage": "https://boycce.github.io/nitro-web/",
6
6
  "main": "./webpack.config.js",
@@ -56,7 +56,6 @@
56
56
  "react-router-dom": "6.24.1",
57
57
  "react-select": "^5.9.0",
58
58
  "react-tracked": "^1.3.0",
59
- "sort-route-addresses-nodeps": "0.0.4",
60
59
  "string-replace-loader": "^3.1.0",
61
60
  "tailwind-merge": "^2.6.0",
62
61
  "typescript": "^5.5.2",
package/webpack.config.js CHANGED
@@ -19,7 +19,6 @@ import { createRequire } from 'module'
19
19
  import { getDirectories } from 'nitro-web/util'
20
20
 
21
21
  const _require = createRequire(import.meta.url)
22
- const pick = (object, list) => list.reduce((o, e) => ((o[e] = object[e]), o), {})
23
22
  const isBuild = process.env.NODE_ENV == 'production'
24
23
  const nitroVersion = _require('./package.json').version
25
24
 
@@ -274,9 +273,11 @@ export const getConfig = (config) => {
274
273
  ],
275
274
  }),
276
275
  new webpack.DefinePlugin({
277
- ISDEMO: !!process.env.isDemo,
278
276
  INJECTED_CONFIG: JSON.stringify({
279
- ...pick(config, config.inject ? config.inject.split(' ') : []),
277
+ ...config.client,
278
+ isDemo: !!process.env.isDemo,
279
+ isStatic: !!process.env.isStatic,
280
+ jwtName: 'nitro-jwt' + (isBuild ? '' : '-' + formatSlug(config.name)),
280
281
  version: process.env.isDemo ? nitroVersion : config.version,
281
282
  }),
282
283
  }),
@@ -357,4 +358,15 @@ function getPublicPath(env, homepage, publicPath) {
357
358
  } else {
358
359
  return '/'
359
360
  }
361
+ }
362
+
363
+ function formatSlug (string) {
364
+ return string
365
+ .toString()
366
+ .toLowerCase()
367
+ .replace(/^[^a-zA-Z]+/, '') // Allow only letters at start.
368
+ .replace(/\s+/g, '-') // Spaces to -
369
+ .replace(/[^a-zA-Z0-9-_]+/g, '') // Remove bad characters.
370
+ .replace(/-+/g, '-') // Replace multiple - with single -
371
+ .replace(/-+$/, '') // Remove trailing -
360
372
  }