@razerspine/webpack-core 1.2.0 → 1.2.3
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 +66 -4
- package/README.md +95 -30
- package/dist/config/base.js +2 -0
- package/dist/config/dev.d.ts +1 -1
- package/dist/config/dev.js +16 -18
- package/dist/config/prod.d.ts +1 -1
- package/dist/config/prod.js +4 -5
- package/dist/validation/validate-core-options.d.ts +2 -0
- package/dist/validation/validate-core-options.js +33 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,31 +8,78 @@ required to ensure correct behavior in both development and production modes.
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
+
## [1.2.3] - 2026-02-17
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **Validation Layer**: Introduced `validateCoreOptions()` inside `createBaseConfig`.
|
|
16
|
+
- Validates `mode`, `scripts`, and `styles` values.
|
|
17
|
+
- Ensures the templates entry directory exists before Webpack initialization.
|
|
18
|
+
- Prevents silent runtime failures in pug-plugin due to invalid configuration.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **Dev Server Default Behavior**: Enabled `open: true` in default `devServer` configuration.
|
|
23
|
+
- Development server now automatically opens the browser.
|
|
24
|
+
- Improves developer experience for starter templates.
|
|
25
|
+
|
|
26
|
+
### Notes
|
|
27
|
+
|
|
28
|
+
- This release does **not introduce breaking changes**.
|
|
29
|
+
- Public API remains unchanged.
|
|
30
|
+
- Existing templates continue to work without modification.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## [1.2.1] - 2026-02-12
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- **Flexible Configurations:** Added an optional `options` argument to both `createDevConfig` and `createProdConfig`.
|
|
39
|
+
- Users can now override default `devServer` settings or Webpack production optimizations without losing the base
|
|
40
|
+
functionality.
|
|
41
|
+
- Integrated `webpack-merge` into `createDevConfig` for safer property merging.
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
|
|
45
|
+
- Updated internal documentation and clarified version history in `CHANGELOG.md`.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
11
49
|
## [1.2.0] - 2026-02-12
|
|
12
50
|
|
|
13
51
|
### Changed
|
|
14
|
-
|
|
52
|
+
|
|
53
|
+
- **Enhanced File Watching:** Updated `createDevConfig` to watch all files recursively in the `src/` directory (
|
|
54
|
+
`src/**/*`). This ensures `webpack-dev-server` reacts to changes in any file type (images, JSON, new assets) without
|
|
55
|
+
manual configuration.
|
|
15
56
|
- **Improved Dev Routing:** Configured `historyApiFallback` in development mode.
|
|
16
57
|
- Set `disableDotRule: true` to allow dots in URLs (useful for complex routing).
|
|
17
|
-
- Added a global rewrite rule to serve `/404.html` for any non-existent paths, enabling better local testing of 404
|
|
18
|
-
|
|
58
|
+
- Added a global rewrite rule to serve `/404.html` for any non-existent paths, enabling better local testing of 404
|
|
59
|
+
error pages and SPA-like navigation.
|
|
60
|
+
- **DevServer Optimization:** Set `hot: false` and `liveReload: true` as a stable default for multi-page template builds
|
|
61
|
+
to ensure consistent page refreshes upon file changes.
|
|
19
62
|
|
|
20
63
|
---
|
|
21
64
|
|
|
22
65
|
## [1.1.7] - 2026-02-11
|
|
23
66
|
|
|
24
67
|
### Changed
|
|
68
|
+
|
|
25
69
|
- Updated `README.md`
|
|
26
70
|
- Updated `package.json` metadata (keywords, published files)
|
|
27
71
|
|
|
28
72
|
### Stable Release Note
|
|
29
|
-
|
|
73
|
+
|
|
74
|
+
- **Important:** Versions prior to 1.1.6 were part of a stabilization phase and are not recommended for production use.
|
|
75
|
+
This release marks the stable baseline.
|
|
30
76
|
|
|
31
77
|
---
|
|
32
78
|
|
|
33
79
|
## [1.1.6] - 2026-02-05
|
|
34
80
|
|
|
35
81
|
### Changed
|
|
82
|
+
|
|
36
83
|
- Updated `package.json` metadata (keywords, published files)
|
|
37
84
|
- Updated `README.md`
|
|
38
85
|
|
|
@@ -41,12 +88,14 @@ required to ensure correct behavior in both development and production modes.
|
|
|
41
88
|
## [1.1.5] - 2026-02-05
|
|
42
89
|
|
|
43
90
|
### Fixed
|
|
91
|
+
|
|
44
92
|
- Stabilized production webpack configuration for pug-plugin driven builds
|
|
45
93
|
- Disabled `splitChunks` and `runtimeChunk` to prevent asset resolution issues
|
|
46
94
|
- Ensured predictable output structure in production mode
|
|
47
95
|
- Reduced risk of entry-related build failures
|
|
48
96
|
|
|
49
97
|
### Notes
|
|
98
|
+
|
|
50
99
|
- This release finalizes the stabilization phase of the production configuration
|
|
51
100
|
- Recommended as a stable baseline for template usage
|
|
52
101
|
|
|
@@ -55,6 +104,7 @@ required to ensure correct behavior in both development and production modes.
|
|
|
55
104
|
## [1.1.4] - 2026-02-05
|
|
56
105
|
|
|
57
106
|
### Fixed
|
|
107
|
+
|
|
58
108
|
- Final stabilization of production configuration
|
|
59
109
|
- Ensured consistent build behavior for pug-plugin driven templates
|
|
60
110
|
|
|
@@ -63,6 +113,7 @@ required to ensure correct behavior in both development and production modes.
|
|
|
63
113
|
## [1.1.0 – 1.1.3] - 2026-02-05
|
|
64
114
|
|
|
65
115
|
### Fixed
|
|
116
|
+
|
|
66
117
|
- Multiple fixes for production configuration edge cases
|
|
67
118
|
- Improved compatibility between pug-plugin, assets loader, and webpack optimization
|
|
68
119
|
- Stabilized production builds for template-driven entry points
|
|
@@ -72,6 +123,7 @@ required to ensure correct behavior in both development and production modes.
|
|
|
72
123
|
## [1.0.9] - 2026-02-05
|
|
73
124
|
|
|
74
125
|
### Fixed
|
|
126
|
+
|
|
75
127
|
- Removed implicit webpack entry from production config
|
|
76
128
|
- Fixed production build failure caused by default webpack entry resolution
|
|
77
129
|
|
|
@@ -80,6 +132,7 @@ required to ensure correct behavior in both development and production modes.
|
|
|
80
132
|
## [1.0.8] - 2026-02-05
|
|
81
133
|
|
|
82
134
|
### Fixed
|
|
135
|
+
|
|
83
136
|
- Fixed `resolve.alias` handling across loaders and pug-plugin
|
|
84
137
|
|
|
85
138
|
---
|
|
@@ -87,6 +140,7 @@ required to ensure correct behavior in both development and production modes.
|
|
|
87
140
|
## [1.0.7] - 2026-02-05
|
|
88
141
|
|
|
89
142
|
### Fixed
|
|
143
|
+
|
|
90
144
|
- Fixed Pug asset resolution in production mode
|
|
91
145
|
- Passed webpack `resolve.alias` into pug-plugin resolver
|
|
92
146
|
- Ensured consistent alias behavior in development and production
|
|
@@ -96,6 +150,7 @@ required to ensure correct behavior in both development and production modes.
|
|
|
96
150
|
## [1.0.6] - 2026-02-05
|
|
97
151
|
|
|
98
152
|
### Fixed
|
|
153
|
+
|
|
99
154
|
- Fixed webpack plugin instance mismatch when used via `npm link`
|
|
100
155
|
- Moved `webpack-dev-server` and `pug-plugin` to `peerDependencies`
|
|
101
156
|
- Ensured a single webpack instance is used in consumer templates
|
|
@@ -105,6 +160,7 @@ required to ensure correct behavior in both development and production modes.
|
|
|
105
160
|
## [1.0.5] - 2026-02-04
|
|
106
161
|
|
|
107
162
|
### Fixed
|
|
163
|
+
|
|
108
164
|
- Explicitly disabled webpack default entry (`./src`)
|
|
109
165
|
- Ensured stable behavior when using pug-plugin as the primary entry system
|
|
110
166
|
|
|
@@ -113,6 +169,7 @@ required to ensure correct behavior in both development and production modes.
|
|
|
113
169
|
## [1.0.4] - 2026-02-04
|
|
114
170
|
|
|
115
171
|
### Fixed
|
|
172
|
+
|
|
116
173
|
- Fixed TypeScript typing for `webpack-dev-server`
|
|
117
174
|
- Properly extended webpack Configuration with devServer types
|
|
118
175
|
|
|
@@ -121,11 +178,13 @@ required to ensure correct behavior in both development and production modes.
|
|
|
121
178
|
## [1.0.3] - 2026-02-04
|
|
122
179
|
|
|
123
180
|
### Fixed
|
|
181
|
+
|
|
124
182
|
- Fixed webpack default entry fallback (`./src`)
|
|
125
183
|
- Prevented webpack from resolving non-existing JS entry when using pug-plugin
|
|
126
184
|
- Stabilized template entry handling via `templatesLoader`
|
|
127
185
|
|
|
128
186
|
### Internal
|
|
187
|
+
|
|
129
188
|
- Clarified responsibility between webpack entry and pug-plugin entry
|
|
130
189
|
|
|
131
190
|
---
|
|
@@ -133,9 +192,12 @@ required to ensure correct behavior in both development and production modes.
|
|
|
133
192
|
## [1.0.2] - 2026-02-04
|
|
134
193
|
|
|
135
194
|
### Fixed
|
|
195
|
+
|
|
136
196
|
- Fixed ENV mode option typing
|
|
137
197
|
- Stabilized base configuration behavior
|
|
138
198
|
|
|
139
199
|
## [Unreleased]
|
|
200
|
+
|
|
140
201
|
### Changed
|
|
202
|
+
|
|
141
203
|
- Updated README.md
|
package/README.md
CHANGED
|
@@ -12,8 +12,9 @@ template-driven builds using `pug-plugin`.
|
|
|
12
12
|
Versions prior to 1.1.6 were part of a stabilization phase and are not recommended for production use.
|
|
13
13
|
|
|
14
14
|
Please use:
|
|
15
|
+
|
|
15
16
|
```bash
|
|
16
|
-
npm install @razerspine/webpack-core@^1.1
|
|
17
|
+
npm install @razerspine/webpack-core@^1.2.1
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
## Designed for
|
|
@@ -28,35 +29,40 @@ templates, but can also be used independently.
|
|
|
28
29
|
|
|
29
30
|
## Design principles
|
|
30
31
|
|
|
31
|
-
- Webpack is responsible for
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
- **Webpack is responsible for**: module resolution, aliases (`resolve.alias`), and asset handling.
|
|
33
|
+
- **Flexibility:** Since v1.2.1, you can override any part of the dev or prod configuration using an optional `options`
|
|
34
|
+
argument.
|
|
35
|
+
- **Stability:** `pug-plugin` is used to compile templates, and asset paths are resolved by webpack.
|
|
36
|
+
- **Template-driven**: Webpack JS entry is intentionally disabled. Builds are driven by template entries in
|
|
37
|
+
`src/views/pages`.
|
|
38
|
+
- **Sensible Defaults**: No aggressive production optimizations (like `splitChunks`) are enabled by default to prevent
|
|
39
|
+
asset resolution issues in templates.
|
|
40
|
+
- **Validated configuration layer (v1.2.2+)**: Core options are validated before build initialization to prevent silent
|
|
41
|
+
runtime failures.
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
Asset paths are resolved by webpack.
|
|
43
|
+
---
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
Builds are driven by template entries.
|
|
45
|
+
## Features
|
|
46
46
|
|
|
47
|
-
-
|
|
48
|
-
|
|
47
|
+
- **Pug templates support** with auto-discovery.
|
|
48
|
+
- **JavaScript / TypeScript** integration.
|
|
49
|
+
- **SCSS / Less** styling support.
|
|
50
|
+
- **Recursive File Watching**: Dev server watches all changes in `src/**/*`.
|
|
51
|
+
- **SPA-friendly Dev Server**: Integrated historyApiFallback (redirects to 404.html).
|
|
52
|
+
- **Customizable**: Easily override devServer or optimization settings.
|
|
53
|
+
- **Configuration validation layer**
|
|
54
|
+
- **Automatic browser open in development (v1.2.2+)**
|
|
49
55
|
|
|
50
56
|
---
|
|
51
57
|
|
|
52
|
-
##
|
|
58
|
+
## What’s New in v1.2.2
|
|
59
|
+
|
|
60
|
+
- Added `validateCoreOptions()` inside `createBaseConfig`
|
|
61
|
+
- Validates `mode`, `scripts`, and `styles`
|
|
62
|
+
- Ensures templates entry directory exists before Webpack starts
|
|
63
|
+
- Dev server now opens the browser automatically (`open: true` by default)
|
|
53
64
|
|
|
54
|
-
|
|
55
|
-
- JavaScript / TypeScript
|
|
56
|
-
- SCSS / Less
|
|
57
|
-
- Environment-aware configuration
|
|
58
|
-
- No hardcoded aliases
|
|
59
|
-
- Production-safe defaults
|
|
65
|
+
> No breaking changes were introduced.
|
|
60
66
|
|
|
61
67
|
---
|
|
62
68
|
|
|
@@ -70,6 +76,8 @@ npm install @razerspine/webpack-core
|
|
|
70
76
|
|
|
71
77
|
## Usage
|
|
72
78
|
|
|
79
|
+
### Basic Setup
|
|
80
|
+
|
|
73
81
|
```js
|
|
74
82
|
const path = require('path');
|
|
75
83
|
const {
|
|
@@ -83,8 +91,8 @@ module.exports = (env = {}, argv = {}) => {
|
|
|
83
91
|
|
|
84
92
|
const baseConfig = createBaseConfig({
|
|
85
93
|
mode,
|
|
86
|
-
scripts: 'js',
|
|
87
|
-
styles: 'less'
|
|
94
|
+
scripts: 'js', // or 'ts'
|
|
95
|
+
styles: 'scss', // or 'less'
|
|
88
96
|
templates: {
|
|
89
97
|
entry: 'src/views/pages',
|
|
90
98
|
},
|
|
@@ -92,19 +100,76 @@ module.exports = (env = {}, argv = {}) => {
|
|
|
92
100
|
alias: {
|
|
93
101
|
'@views': path.resolve(process.cwd(), 'src/views'),
|
|
94
102
|
'@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
103
|
},
|
|
98
104
|
},
|
|
99
105
|
});
|
|
100
106
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
107
|
+
if (mode === 'development') {
|
|
108
|
+
return createDevConfig(baseConfig);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return createProdConfig(baseConfig);
|
|
104
112
|
};
|
|
105
113
|
```
|
|
106
114
|
|
|
115
|
+
### Customizing Configuration (v1.2.1+)
|
|
116
|
+
|
|
117
|
+
You can now pass an optional second argument to `createDevConfig` and `createProdConfig` to override defaults:
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
// Customizing the Dev Server (port, open browser, etc.)
|
|
121
|
+
if (mode === 'development') {
|
|
122
|
+
return createDevConfig(baseConfig, {
|
|
123
|
+
port: 3000,
|
|
124
|
+
open: true,
|
|
125
|
+
// extra devServer options...
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Customizing Production (minification, performance hints, etc.)
|
|
130
|
+
if (mode === 'production') {
|
|
131
|
+
return createProdConfig(baseConfig, {
|
|
132
|
+
performance: {
|
|
133
|
+
hints: 'warning',
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
107
139
|
---
|
|
108
140
|
|
|
141
|
+
## API Reference
|
|
142
|
+
|
|
143
|
+
`createBaseConfig(options)`
|
|
144
|
+
|
|
145
|
+
Core configuration factory.
|
|
146
|
+
|
|
147
|
+
**Options include**:
|
|
148
|
+
|
|
149
|
+
- `mode` — `'development' | 'production'`
|
|
150
|
+
- `scripts` — `'js' | 'ts'`
|
|
151
|
+
- `styles` — `'scss' | 'less'`
|
|
152
|
+
- `templates.entry` — Path to template pages directory
|
|
153
|
+
- `resolve.alias` — Webpack aliases
|
|
154
|
+
|
|
155
|
+
All options are validated before initialization.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
`createDevConfig(baseConfig, options?)`
|
|
160
|
+
|
|
161
|
+
- `baseConfig`: The configuration returned by createBaseConfig.
|
|
162
|
+
- `options`: (Optional) webpack-dev-server configuration object.
|
|
163
|
+
- **Default behavior**: Watches `src/**/*`, uses port `8080`, and rewrites 404s to `/404.html`.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
`createProdConfig(baseConfig, options?)`
|
|
168
|
+
|
|
169
|
+
- `baseConfig`: The configuration returned by createBaseConfig.
|
|
170
|
+
- `options`: (Optional) Webpack configuration object for production overrides.
|
|
171
|
+
- **Default behavior**: Enables source maps, minification, and disables `splitChunks` for template compatibility.
|
|
172
|
+
|
|
109
173
|
## 📄 License
|
|
174
|
+
|
|
110
175
|
This project is licensed under the ISC License.
|
package/dist/config/base.js
CHANGED
|
@@ -9,8 +9,10 @@ const scripts_1 = require("../loaders/scripts");
|
|
|
9
9
|
const styles_1 = require("../loaders/styles");
|
|
10
10
|
const templates_1 = require("../loaders/templates");
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const validate_core_options_1 = require("../validation/validate-core-options");
|
|
12
13
|
function createBaseConfig(options) {
|
|
13
14
|
var _a, _b, _c, _d;
|
|
15
|
+
(0, validate_core_options_1.validateCoreOptions)(options);
|
|
14
16
|
const mode = (_a = options.mode) !== null && _a !== void 0 ? _a : 'development';
|
|
15
17
|
return {
|
|
16
18
|
mode,
|
package/dist/config/dev.d.ts
CHANGED
|
@@ -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 {};
|
package/dist/config/dev.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createDevConfig = createDevConfig;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
open: true,
|
|
9
|
+
liveReload: true,
|
|
10
|
+
compress: true,
|
|
11
|
+
port: 8080,
|
|
12
|
+
watchFiles: ['src/**/*'],
|
|
13
|
+
historyApiFallback: {
|
|
14
|
+
disableDotRule: true,
|
|
15
|
+
rewrites: [{ from: /./, to: '/404.html' }]
|
|
22
16
|
}
|
|
23
17
|
};
|
|
18
|
+
return (0, webpack_merge_1.merge)(baseConfig, {
|
|
19
|
+
devtool: 'source-map',
|
|
20
|
+
devServer: (0, webpack_merge_1.merge)(defaultDevServer, options)
|
|
21
|
+
});
|
|
24
22
|
}
|
package/dist/config/prod.d.ts
CHANGED
|
@@ -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;
|
package/dist/config/prod.js
CHANGED
|
@@ -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
|
-
|
|
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
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.validateCoreOptions = validateCoreOptions;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
function validateCoreOptions(options) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
if (!options) {
|
|
12
|
+
throw new Error('[webpack-core] Options are required.');
|
|
13
|
+
}
|
|
14
|
+
const { mode, scripts, styles } = options;
|
|
15
|
+
// --- mode
|
|
16
|
+
if (!['development', 'production'].includes(mode)) {
|
|
17
|
+
throw new Error(`[webpack-core] Invalid mode "${mode}". Expected "development" or "production".`);
|
|
18
|
+
}
|
|
19
|
+
// --- scripts
|
|
20
|
+
if (!['js', 'ts'].includes(scripts)) {
|
|
21
|
+
throw new Error(`[webpack-core] Invalid scripts option "${scripts}". Expected "js" or "ts".`);
|
|
22
|
+
}
|
|
23
|
+
// --- styles
|
|
24
|
+
if (!['scss', 'less'].includes(styles)) {
|
|
25
|
+
throw new Error(`[webpack-core] Invalid styles option "${styles}". Expected "scss" or "less".`);
|
|
26
|
+
}
|
|
27
|
+
// --- templates entry
|
|
28
|
+
const entryRelative = (_b = (_a = options.templates) === null || _a === void 0 ? void 0 : _a.entry) !== null && _b !== void 0 ? _b : 'src/views/pages';
|
|
29
|
+
const entryAbsolute = path_1.default.resolve(process.cwd(), entryRelative);
|
|
30
|
+
if (!fs_1.default.existsSync(entryAbsolute)) {
|
|
31
|
+
throw new Error(`[webpack-core] Templates entry directory does not exist: ${entryAbsolute}`);
|
|
32
|
+
}
|
|
33
|
+
}
|