@nitro-web/webpack 0.0.60 → 0.0.62

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 -1
  2. package/webpack.config.js +12 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitro-web/webpack",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "repository": "github:boycce/nitro-web",
5
5
  "homepage": "https://boycce.github.io/nitro-web/",
6
6
  "main": "./webpack.config.js",
package/webpack.config.js CHANGED
@@ -30,8 +30,11 @@ const nitroVersion = _require('./package.json').version
30
30
 
31
31
  // process.traceDeprecation = true
32
32
  export const getConfig = (config) => {
33
- const { clientDir, componentsDir, distDir, imgsDir } = getDirectories(path, config.pwd)
34
- const publicPath = getPublicPath(config.env, config.homepage, config.publicPath)
33
+ const { client, name='', pwd, env='development', homepage, publicPath, version } = config
34
+ const { clientDir, componentsDir, distDir, imgsDir } = getDirectories(path, pwd)
35
+ const publicPathResolved = getPublicPath(env, homepage, publicPath)
36
+
37
+ if (!name) throw new Error('No name found in config environement variables?')
35
38
 
36
39
  return (env, argv) => [{
37
40
  devtool: isBuild ? false : 'source-map',
@@ -103,7 +106,7 @@ export const getConfig = (config) => {
103
106
  // }),
104
107
  postcssNested,
105
108
  postcssFor,
106
- tailwindcss({ config: path.resolve(config.pwd, 'tailwind.config.js') }),
109
+ tailwindcss({ config: path.resolve(pwd, 'tailwind.config.js') }),
107
110
  autoprefixer,
108
111
  ],
109
112
  },
@@ -142,7 +145,7 @@ export const getConfig = (config) => {
142
145
  ['babel-plugin-macros', {
143
146
  'twin': {
144
147
  preset: 'emotion',
145
- config: path.resolve(config.pwd, 'tailwind.config.js'),
148
+ config: path.resolve(pwd, 'tailwind.config.js'),
146
149
  },
147
150
  }],
148
151
  // 'react-refresh/babel', // !isBuild && _require.resolve('react-refresh/babel'),
@@ -245,7 +248,7 @@ export const getConfig = (config) => {
245
248
  // Because of this we manually need to prefix all output filenames with `assets/`.
246
249
  filename: `assets/bundle.[name]${isBuild ? '.[contenthash]' : ''}.js`,
247
250
  path: distDir,
248
- publicPath: publicPath,
251
+ publicPath: publicPathResolved,
249
252
  },
250
253
  performance: {
251
254
  hints: false,
@@ -274,11 +277,11 @@ export const getConfig = (config) => {
274
277
  }),
275
278
  new webpack.DefinePlugin({
276
279
  INJECTED_CONFIG: JSON.stringify({
277
- ...config.client,
280
+ ...(client||{}),
278
281
  isDemo: !!process.env.isDemo,
279
282
  isStatic: !!process.env.isStatic,
280
- jwtName: 'nitro-jwt' + (isBuild ? '' : '-' + formatSlug(config.name)),
281
- version: process.env.isDemo ? nitroVersion : config.version,
283
+ jwtName: 'nitro-jwt' + (isBuild ? '' : '-' + formatSlug(name)),
284
+ version: process.env.isDemo ? nitroVersion : version,
282
285
  }),
283
286
  }),
284
287
  new ESLintPlugin({
@@ -287,7 +290,7 @@ export const getConfig = (config) => {
287
290
  }),
288
291
  new MiniCssExtractPlugin({ filename: `assets/bundle.[name]${isBuild ? '.[contenthash]' : ''}.css` }),
289
292
  new HtmlWebpackPlugin({ template: clientDir + 'index.html', filename: distDir + 'index.html' }),
290
- new InterpolateHtmlPlugin(HtmlWebpackPlugin, { PUBLIC_PATH: publicPath, NAME: config.name }),
293
+ new InterpolateHtmlPlugin(HtmlWebpackPlugin, { PUBLIC_PATH: publicPathResolved, NAME: name }),
291
294
  new CleanTerminalPlugin({ skipFirstRun: true }),
292
295
  // !isBuild && new ReactRefreshWebpackPlugin({ overlay: false }),
293
296
  ].filter(Boolean),