@razerspine/webpack-core 1.7.2 → 1.8.0

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/CHANGELOG.md CHANGED
@@ -8,6 +8,33 @@ required to ensure correct behavior in both development and production modes.
8
8
 
9
9
  ---
10
10
 
11
+ ## [1.8.0] - 2026-03-13
12
+
13
+ ### Added
14
+
15
+ - **Automated Deployment Assets Generation**
16
+ - Integrated `RoutingPlugin` into `createProdConfig` to handle host-specific routing files.
17
+ - **Vercel Support**: Automatically generates `vercel.json` with correct rewrite rules based on `appType`.
18
+ - **Netlify/Cloudflare Support**: Automatically generates `_redirects` file.
19
+ - **Zero-Config Deployment**: Routing files are generated in-memory during the build and emitted directly to the
20
+ `dist` folder.
21
+ - **Enhanced SPA Fallback**
22
+ - Added automatic generation of `404.html` (as a copy of `index.html`) for SPA mode.
23
+ - Ensures seamless routing on platforms like **GitHub Pages** without manual configuration.
24
+
25
+ ### Fixed
26
+
27
+ - **Type Safety**: Improved Webpack 5 internal typing for asset emission using `sources.RawSource`.
28
+ - **Build Reliability**: Replaced `copy-webpack-plugin` for generated assets with a native Webpack emission strategy to
29
+ prevent "file not found" errors during build.
30
+
31
+ ### Changed
32
+
33
+ - **Production Alignment**: `createProdConfig` now actively reads `_meta.appType` from `LoaderOptionsPlugin` to
34
+ synchronize routing logic with the development server.
35
+
36
+ ---
37
+
11
38
  ## [1.7.2] - 2026-02-22
12
39
 
13
40
  ### Added
@@ -29,7 +56,8 @@ required to ensure correct behavior in both development and production modes.
29
56
  - Removed global `loaderOptions` from `PugPlugin` to delegate responsibility to the new specialized `pugRule()`.
30
57
  - Improved compatibility between dynamic imports and static page generation.
31
58
  - **Clean Architecture Alignment**
32
- - Updated `base.ts` to include `pugRule()` in `module.rules`, establishing a standard for how assets are resolved across all 8
59
+ - Updated `base.ts` to include `pugRule()` in `module.rules`, establishing a standard for how assets are resolved
60
+ across all 8
33
61
  - template variations (JS/TS, SCSS/Less, MPA/SPA).
34
62
 
35
63
  ---
package/README.md CHANGED
@@ -31,6 +31,8 @@ Can be used independently in any Pug-based project.
31
31
  - Config validation layer
32
32
  - Centralized options normalization (v1.7.1+)
33
33
  - Fully customizable dev & prod configs
34
+ - **New (v1.8.0) Automatic Deployment Configs**: Generates `_redirects` and `vercel.json` automatically.
35
+ - **New (v1.8.0) GitHub Pages SPA Support**: Automatic `404.html` fallback for single-page apps.
34
36
 
35
37
  ---
36
38
 
@@ -203,7 +205,11 @@ All options are validated before initialization.
203
205
 
204
206
  - `baseConfig`: The configuration returned by createBaseConfig.
205
207
  - `options`: (Optional) Webpack configuration object for production overrides.
206
- - **Default behavior**: Enables source maps, minification, and disables `splitChunks` for template compatibility.
208
+ - **Default behavior**:
209
+ - Enables source maps and minification.
210
+ - Disables `splitChunks` for template compatibility.
211
+ - **New**: Generates routing assets (`_redirects`, `vercel.json`) based on `appType`.
212
+ - **New**: Creates `404.html` fallback for SPA mode.
207
213
 
208
214
  ---
209
215
 
@@ -1,2 +1,2 @@
1
- import type { Configuration } from 'webpack';
1
+ import { Configuration } from 'webpack';
2
2
  export declare function createProdConfig(baseConfig: Configuration, options?: Configuration): Configuration;
@@ -1,8 +1,48 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createProdConfig = createProdConfig;
4
+ const webpack_1 = require("webpack");
4
5
  const webpack_merge_1 = require("webpack-merge");
6
+ function getRedirects(appType) {
7
+ return appType === 'spa'
8
+ ? '/* /index.html 200\n'
9
+ : '/* /404.html 404\n';
10
+ }
11
+ function getVercelConfig(appType) {
12
+ const config = appType === 'spa'
13
+ ? { routes: [{ src: '/(.*)', dest: '/index.html' }] }
14
+ : {
15
+ routes: [
16
+ { handle: 'filesystem' },
17
+ { src: '/(.*)', dest: '/404.html', status: 404 }
18
+ ]
19
+ };
20
+ return JSON.stringify(config, null, 2);
21
+ }
5
22
  function createProdConfig(baseConfig, options = {}) {
23
+ var _a, _b, _c, _d, _e;
24
+ const loaderPlugin = (_a = baseConfig.plugins) === null || _a === void 0 ? void 0 : _a.find((p) => p instanceof webpack_1.LoaderOptionsPlugin);
25
+ const appType = (_e = (_d = (_c = (_b = loaderPlugin === null || loaderPlugin === void 0 ? void 0 : loaderPlugin.options) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c._meta) === null || _d === void 0 ? void 0 : _d.appType) !== null && _e !== void 0 ? _e : 'mpa';
26
+ const routingPlugin = {
27
+ apply(compiler) {
28
+ compiler.hooks.thisCompilation.tap('RoutingPlugin', (compilation) => {
29
+ compilation.hooks.processAssets.tap({
30
+ name: 'RoutingPlugin',
31
+ stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
32
+ }, () => {
33
+ const { RawSource } = webpack_1.sources;
34
+ compilation.emitAsset('_redirects', new RawSource(getRedirects(appType)));
35
+ compilation.emitAsset('vercel.json', new RawSource(getVercelConfig(appType)));
36
+ if (appType === 'spa') {
37
+ const indexAsset = compilation.getAsset('index.html');
38
+ if (indexAsset) {
39
+ compilation.emitAsset('404.html', indexAsset.source);
40
+ }
41
+ }
42
+ });
43
+ });
44
+ },
45
+ };
6
46
  const defaultConfig = {
7
47
  devtool: 'source-map',
8
48
  optimization: {
@@ -13,6 +53,7 @@ function createProdConfig(baseConfig, options = {}) {
13
53
  performance: {
14
54
  hints: false,
15
55
  },
56
+ plugins: [routingPlugin],
16
57
  };
17
58
  return (0, webpack_merge_1.merge)(baseConfig, defaultConfig, options);
18
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razerspine/webpack-core",
3
- "version": "1.7.2",
3
+ "version": "1.8.0",
4
4
  "description": "Core webpack config and loaders for starter templates",
5
5
  "keywords": [
6
6
  "webpack",