@razerspine/webpack-core 1.2.0 → 1.2.1

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,18 @@ required to ensure correct behavior in both development and production modes.
8
8
 
9
9
  ---
10
10
 
11
+ ## [1.2.1] - 2026-02-12
12
+
13
+ ### Added
14
+ - **Flexible Configurations:** Added an optional `options` argument to both `createDevConfig` and `createProdConfig`.
15
+ - Users can now override default `devServer` settings or Webpack production optimizations without losing the base functionality.
16
+ - Integrated `webpack-merge` into `createDevConfig` for safer property merging.
17
+
18
+ ### Fixed
19
+ - Updated internal documentation and clarified version history in `CHANGELOG.md`.
20
+
21
+ ---
22
+
11
23
  ## [1.2.0] - 2026-02-12
12
24
 
13
25
  ### Changed
package/README.md CHANGED
@@ -13,7 +13,7 @@ Versions prior to 1.1.6 were part of a stabilization phase and are not recommend
13
13
 
14
14
  Please use:
15
15
  ```bash
16
- npm install @razerspine/webpack-core@^1.1.6
16
+ npm install @razerspine/webpack-core@^1.2.1
17
17
  ```
18
18
 
19
19
  ## Designed for
@@ -28,35 +28,22 @@ templates, but can also be used independently.
28
28
 
29
29
  ## Design principles
30
30
 
31
- - Webpack is responsible for:
32
- - module resolution
33
- - aliases (`resolve.alias`)
34
- - asset handling
35
-
36
- - Loaders and plugins:
37
- - do not define aliases
38
- - do not depend on UI kits
39
- - do not assume project structure
40
-
41
- - `pug-plugin` is used only to compile templates
42
- Asset paths are resolved by webpack.
43
-
44
- - Webpack JS entry is intentionally disabled
45
- Builds are driven by template entries.
46
-
47
- - No aggressive production optimizations by default
48
- (e.g. no `splitChunks`)
31
+ - **Webpack is responsible for**: module resolution, aliases (`resolve.alias`), and asset handling.
32
+ - **Flexibility:** Since v1.2.1, you can override any part of the dev or prod configuration using an optional `options` argument.
33
+ - **Stability:** `pug-plugin` is used to compile templates, and asset paths are resolved by webpack.
34
+ - **Template-driven**: Webpack JS entry is intentionally disabled. Builds are driven by template entries in `src/views/pages`.
35
+ - **Sensible Defaults**: No aggressive production optimizations (like `splitChunks`) are enabled by default to prevent asset resolution issues in templates.
49
36
 
50
37
  ---
51
38
 
52
39
  ## Features
53
40
 
54
- - Pug templates support
55
- - JavaScript / TypeScript
56
- - SCSS / Less
57
- - Environment-aware configuration
58
- - No hardcoded aliases
59
- - Production-safe defaults
41
+ - **Pug templates support** with auto-discovery.
42
+ - **JavaScript / TypeScript** integration.
43
+ - **SCSS / Less** styling support.
44
+ - **Recursive File Watching**: Dev server watches all changes in src/**/*.
45
+ - **SPA-friendly Dev Server**: Integrated historyApiFallback (redirects to 404.html).
46
+ - **Customizable**: Easily override devServer or optimization settings.
60
47
 
61
48
  ---
62
49
 
@@ -70,6 +57,8 @@ npm install @razerspine/webpack-core
70
57
 
71
58
  ## Usage
72
59
 
60
+ ### Basic Setup
61
+
73
62
  ```js
74
63
  const path = require('path');
75
64
  const {
@@ -83,8 +72,8 @@ module.exports = (env = {}, argv = {}) => {
83
72
 
84
73
  const baseConfig = createBaseConfig({
85
74
  mode,
86
- scripts: 'js',
87
- styles: 'less',
75
+ scripts: 'js', // or 'ts'
76
+ styles: 'scss', // or 'less'
88
77
  templates: {
89
78
  entry: 'src/views/pages',
90
79
  },
@@ -92,19 +81,57 @@ module.exports = (env = {}, argv = {}) => {
92
81
  alias: {
93
82
  '@views': path.resolve(process.cwd(), 'src/views'),
94
83
  '@styles': path.resolve(process.cwd(), 'src/assets/styles'),
95
- '@scripts': path.resolve(process.cwd(), 'src/assets/scripts'),
96
- '@images': path.resolve(process.cwd(), 'src/assets/images'),
97
84
  },
98
85
  },
99
86
  });
100
87
 
101
- return mode === 'development'
102
- ? createDevConfig(baseConfig)
103
- : createProdConfig(baseConfig);
88
+ if (mode === 'development') {
89
+ return createDevConfig(baseConfig);
90
+ }
91
+
92
+ return createProdConfig(baseConfig);
104
93
  };
105
94
  ```
106
95
 
96
+ ### Customizing Configuration (v1.2.1+)
97
+
98
+ You can now pass an optional second argument to `createDevConfig` and `createProdConfig` to override defaults:
99
+
100
+ ```js
101
+ // Customizing the Dev Server (port, open browser, etc.)
102
+ if (mode === 'development') {
103
+ return createDevConfig(baseConfig, {
104
+ port: 3000,
105
+ open: true,
106
+ // extra devServer options...
107
+ });
108
+ }
109
+
110
+ // Customizing Production (minification, performance hints, etc.)
111
+ if (mode === 'production') {
112
+ return createProdConfig(baseConfig, {
113
+ performance: {
114
+ hints: 'warning',
115
+ }
116
+ });
117
+ }
118
+ ```
119
+
107
120
  ---
108
121
 
122
+ ## API Reference
123
+
124
+ `createDevConfig(baseConfig, options?)`
125
+
126
+ - `baseConfig`: The configuration returned by createBaseConfig.
127
+ - `options`: (Optional) webpack-dev-server configuration object.
128
+ - **Default behavior**: Watches `src/**/*`, uses port `8080`, and rewrites 404s to `/404.html`.
129
+
130
+ `createProdConfig(baseConfig, options?)`
131
+
132
+ - `baseConfig`: The configuration returned by createBaseConfig.
133
+ - `options`: (Optional) Webpack configuration object for production overrides.
134
+ - **Default behavior**: Enables source maps, minification, and disables `splitChunks` for template compatibility.
135
+
109
136
  ## 📄 License
110
137
  This project is licensed under the ISC License.
@@ -3,5 +3,5 @@ import type { Configuration as DevServerConfiguration } from 'webpack-dev-server
3
3
  type DevConfig = WebpackConfiguration & {
4
4
  devServer?: DevServerConfiguration;
5
5
  };
6
- export declare function createDevConfig(baseConfig: WebpackConfiguration): DevConfig;
6
+ export declare function createDevConfig(baseConfig: WebpackConfiguration, options?: DevServerConfiguration): DevConfig;
7
7
  export {};
@@ -1,24 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createDevConfig = createDevConfig;
4
- function createDevConfig(baseConfig) {
5
- return {
6
- ...baseConfig,
7
- devtool: 'source-map',
8
- devServer: {
9
- hot: false,
10
- liveReload: true,
11
- compress: true,
12
- port: 8080,
13
- watchFiles: [
14
- 'src/**/*',
15
- ],
16
- historyApiFallback: {
17
- disableDotRule: true,
18
- rewrites: [
19
- { from: /./, to: '/404.html' }
20
- ]
21
- }
4
+ const webpack_merge_1 = require("webpack-merge");
5
+ function createDevConfig(baseConfig, options = {}) {
6
+ const defaultDevServer = {
7
+ hot: false,
8
+ liveReload: true,
9
+ compress: true,
10
+ port: 8080,
11
+ watchFiles: ['src/**/*'],
12
+ historyApiFallback: {
13
+ disableDotRule: true,
14
+ rewrites: [{ from: /./, to: '/404.html' }]
22
15
  }
23
16
  };
17
+ return (0, webpack_merge_1.merge)(baseConfig, {
18
+ devtool: 'source-map',
19
+ devServer: (0, webpack_merge_1.merge)(defaultDevServer, options)
20
+ });
24
21
  }
@@ -1,2 +1,2 @@
1
1
  import type { Configuration } from 'webpack';
2
- export declare function createProdConfig(baseConfig: Configuration): Configuration;
2
+ export declare function createProdConfig(baseConfig: Configuration, options?: Configuration): Configuration;
@@ -2,18 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createProdConfig = createProdConfig;
4
4
  const webpack_merge_1 = require("webpack-merge");
5
- function createProdConfig(baseConfig) {
6
- return (0, webpack_merge_1.merge)(baseConfig, {
5
+ function createProdConfig(baseConfig, options = {}) {
6
+ const defaultConfig = {
7
7
  devtool: 'source-map',
8
8
  optimization: {
9
9
  minimize: true,
10
- // ⚠️ splitChunks deliberately disabled
11
- // pug-plugin manages assets & entries itself
12
10
  splitChunks: false,
13
11
  runtimeChunk: false,
14
12
  },
15
13
  performance: {
16
14
  hints: false,
17
15
  },
18
- });
16
+ };
17
+ return (0, webpack_merge_1.merge)(baseConfig, defaultConfig, options);
19
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razerspine/webpack-core",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Core webpack config and loaders for starter templates",
5
5
  "keywords": [
6
6
  "webpack",