@razerspine/build 1.0.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 +750 -0
- package/LICENSE +15 -0
- package/README.md +232 -0
- package/dist/core/config-meta.d.ts +33 -0
- package/dist/core/config-meta.js +27 -0
- package/dist/core/create-base-config.d.ts +52 -0
- package/dist/core/create-base-config.js +180 -0
- package/dist/core/create-dev-config.d.ts +18 -0
- package/dist/core/create-dev-config.js +68 -0
- package/dist/core/create-prod-config.d.ts +12 -0
- package/dist/core/create-prod-config.js +56 -0
- package/dist/core/define-config.d.ts +67 -0
- package/dist/core/define-config.js +81 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.js +14 -0
- package/dist/hosting/detect-hosting.d.ts +2 -0
- package/dist/hosting/detect-hosting.js +14 -0
- package/dist/hosting/get-redirects.d.ts +2 -0
- package/dist/hosting/get-redirects.js +8 -0
- package/dist/hosting/get-vercel-config.d.ts +2 -0
- package/dist/hosting/get-vercel-config.js +22 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +27 -0
- package/dist/options/index.d.ts +2 -0
- package/dist/options/index.js +5 -0
- package/dist/options/normalize-options.d.ts +14 -0
- package/dist/options/normalize-options.js +38 -0
- package/dist/options/resolve-options.d.ts +3 -0
- package/dist/options/resolve-options.js +9 -0
- package/dist/options/validate-options.d.ts +2 -0
- package/dist/options/validate-options.js +28 -0
- package/dist/plugins/hosting-routing-plugin.d.ts +12 -0
- package/dist/plugins/hosting-routing-plugin.js +54 -0
- package/dist/plugins/html-templates-plugin.d.ts +16 -0
- package/dist/plugins/html-templates-plugin.js +82 -0
- package/dist/plugins/pug-templates-plugin.d.ts +16 -0
- package/dist/plugins/pug-templates-plugin.js +90 -0
- package/dist/presets/react/index.d.ts +1 -0
- package/dist/presets/react/index.js +5 -0
- package/dist/presets/react/react-preset.d.ts +66 -0
- package/dist/presets/react/react-preset.js +198 -0
- package/dist/rules/assets-rule.d.ts +27 -0
- package/dist/rules/assets-rule.js +32 -0
- package/dist/rules/index.d.ts +4 -0
- package/dist/rules/index.js +11 -0
- package/dist/rules/pug-rule.d.ts +16 -0
- package/dist/rules/pug-rule.js +27 -0
- package/dist/rules/scripts-rule.d.ts +15 -0
- package/dist/rules/scripts-rule.js +22 -0
- package/dist/rules/styles-rule.d.ts +21 -0
- package/dist/rules/styles-rule.js +28 -0
- package/dist/types/app-type.d.ts +1 -0
- package/dist/types/app-type.js +2 -0
- package/dist/types/base-webpack-config-type.d.ts +2 -0
- package/dist/types/base-webpack-config-type.js +2 -0
- package/dist/types/build-plugin-type.d.ts +24 -0
- package/dist/types/build-plugin-type.js +2 -0
- package/dist/types/config-option-type.d.ts +120 -0
- package/dist/types/config-option-type.js +2 -0
- package/dist/types/hosting-type.d.ts +1 -0
- package/dist/types/hosting-type.js +2 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +2 -0
- package/dist/types/mode-type.d.ts +1 -0
- package/dist/types/mode-type.js +2 -0
- package/dist/types/script-type.d.ts +1 -0
- package/dist/types/script-type.js +2 -0
- package/dist/types/style-type.d.ts +1 -0
- package/dist/types/style-type.js +2 -0
- package/dist/types/templates-type.d.ts +1 -0
- package/dist/types/templates-type.js +2 -0
- package/dist/utils/dedupe-plugins.d.ts +5 -0
- package/dist/utils/dedupe-plugins.js +20 -0
- package/dist/utils/dedupe-rules.d.ts +9 -0
- package/dist/utils/dedupe-rules.js +27 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/text-capitalize.d.ts +1 -0
- package/dist/utils/text-capitalize.js +6 -0
- package/package.json +91 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Configuration, RuleSetRule, WebpackPluginInstance } from 'webpack';
|
|
2
|
+
import { AppType } from 'app-type';
|
|
3
|
+
import { StyleType } from 'style-type';
|
|
4
|
+
import { ScriptType } from 'script-type';
|
|
5
|
+
import { ModeType } from 'mode-type';
|
|
6
|
+
import { TemplatesType } from 'templates-type';
|
|
7
|
+
import { BuildPluginType } from 'build-plugin-type';
|
|
8
|
+
/**
|
|
9
|
+
* Options for configuring the core build process.
|
|
10
|
+
*/
|
|
11
|
+
export type ConfigOptionType = {
|
|
12
|
+
/** Build mode: 'development' or 'production' */
|
|
13
|
+
mode: ModeType;
|
|
14
|
+
/** Script processing options JavaScript or TypeScript */
|
|
15
|
+
scripts: ScriptType;
|
|
16
|
+
/** Styling processing options SCSS or Less */
|
|
17
|
+
styles: StyleType;
|
|
18
|
+
/** Architecture type: 'spa' (Single Page) or 'mpa' (Multi Page) */
|
|
19
|
+
appType?: AppType;
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for HTML/Pug templates
|
|
22
|
+
*/
|
|
23
|
+
templates?: {
|
|
24
|
+
/**
|
|
25
|
+
* Template engine type
|
|
26
|
+
* - 'pug' → uses PugTemplatesPlugin
|
|
27
|
+
* - 'html' → uses HtmlTemplatesPlugin
|
|
28
|
+
* - 'none' → disables template handling (React/Vue/custom setups)
|
|
29
|
+
*
|
|
30
|
+
* @default 'pug'
|
|
31
|
+
*/
|
|
32
|
+
type?: TemplatesType;
|
|
33
|
+
/**
|
|
34
|
+
* Path to the templates entry
|
|
35
|
+
*
|
|
36
|
+
* SPA:
|
|
37
|
+
* - single file (e.g. src/views/app.pug / index.html)
|
|
38
|
+
*
|
|
39
|
+
* MPA:
|
|
40
|
+
* - directory with pages
|
|
41
|
+
*
|
|
42
|
+
* @default 'src/views/app.pug' (SPA) or 'src/views/pages' (MPA)
|
|
43
|
+
*/
|
|
44
|
+
entry?: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Custom Webpack module rules control.
|
|
48
|
+
*/
|
|
49
|
+
rules?: {
|
|
50
|
+
/**
|
|
51
|
+
* Extend internal rules (safe).
|
|
52
|
+
* Rules will be appended to the default pipeline.
|
|
53
|
+
*/
|
|
54
|
+
extend?: RuleSetRule[];
|
|
55
|
+
/**
|
|
56
|
+
* ⚠️ Overrides ALL internal rules completely.
|
|
57
|
+
*
|
|
58
|
+
* Disables:
|
|
59
|
+
* - assetsRule
|
|
60
|
+
* - scriptsRule
|
|
61
|
+
* - stylesRule
|
|
62
|
+
* - pugRule (if enabled)
|
|
63
|
+
*
|
|
64
|
+
* Use only if you fully control the webpack pipeline.
|
|
65
|
+
*/
|
|
66
|
+
override?: RuleSetRule[];
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Custom Webpack plugins control.
|
|
70
|
+
*/
|
|
71
|
+
plugins?: {
|
|
72
|
+
/**
|
|
73
|
+
* Extend internal plugins (safe).
|
|
74
|
+
* Plugins will be appended after core plugins.
|
|
75
|
+
*/
|
|
76
|
+
extend?: WebpackPluginInstance[];
|
|
77
|
+
/**
|
|
78
|
+
* ⚠️ Overrides ALL internal plugins completely.
|
|
79
|
+
*
|
|
80
|
+
* Disables:
|
|
81
|
+
* - PugTemplatesPlugin / HtmlTemplatesPlugin
|
|
82
|
+
* - HostingRoutingPlugin (in production)
|
|
83
|
+
*
|
|
84
|
+
* Use only if you fully control plugin lifecycle.
|
|
85
|
+
*/
|
|
86
|
+
override?: WebpackPluginInstance[];
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Webpack resolve configuration (aliases, extensions, etc.)
|
|
90
|
+
* This is merged into the final Webpack config.
|
|
91
|
+
*/
|
|
92
|
+
resolve?: Configuration['resolve'];
|
|
93
|
+
/**
|
|
94
|
+
* Build plugins (lite extension API)
|
|
95
|
+
*
|
|
96
|
+
* Allows hooking into config generation lifecycle
|
|
97
|
+
* without breaking webpack compatibility.
|
|
98
|
+
*
|
|
99
|
+
* Plugins can:
|
|
100
|
+
* - modify config before/after creation
|
|
101
|
+
* - inject rules/plugins programmatically
|
|
102
|
+
* - extend dev/prod behavior
|
|
103
|
+
*
|
|
104
|
+
* This is NOT a webpack plugin system replacement.
|
|
105
|
+
* It is a higher-level orchestration layer.
|
|
106
|
+
*
|
|
107
|
+
* Example:
|
|
108
|
+
* ```ts
|
|
109
|
+
* {
|
|
110
|
+
* name: 'react-support',
|
|
111
|
+
* setup(ctx) {
|
|
112
|
+
* ctx.hooks.extendConfig.tap(config => {
|
|
113
|
+
* config.resolve.extensions.push('.jsx', '.tsx');
|
|
114
|
+
* });
|
|
115
|
+
* }
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
buildPlugins?: BuildPluginType[];
|
|
120
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type HostingType = 'netlify' | 'vercel' | 'cloudflare' | 'github' | 'static';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { AppType } from './app-type';
|
|
2
|
+
export type { BaseWebpackConfigType } from './base-webpack-config-type';
|
|
3
|
+
export type { ConfigOptionType } from './config-option-type';
|
|
4
|
+
export type { HostingType } from './hosting-type';
|
|
5
|
+
export type { ModeType } from './mode-type';
|
|
6
|
+
export type { ScriptType } from './script-type';
|
|
7
|
+
export type { StyleType } from './style-type';
|
|
8
|
+
export type { TemplatesType } from './templates-type';
|
|
9
|
+
export type { BuildContextType, BuildPluginType } from './build-plugin-type';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ModeType = 'development' | 'production';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ScriptType = 'js' | 'ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type StyleType = 'scss' | 'less';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TemplatesType = 'pug' | 'html' | 'none';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dedupePlugins = dedupePlugins;
|
|
4
|
+
/**
|
|
5
|
+
* Prevent duplicate plugins (by constructor name)
|
|
6
|
+
*/
|
|
7
|
+
function dedupePlugins(plugins) {
|
|
8
|
+
const seen = new Set();
|
|
9
|
+
return plugins.filter((plugin) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const name = (_a = plugin === null || plugin === void 0 ? void 0 : plugin.constructor) === null || _a === void 0 ? void 0 : _a.name;
|
|
12
|
+
if (!name)
|
|
13
|
+
return true;
|
|
14
|
+
if (seen.has(name)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
seen.add(name);
|
|
18
|
+
return true;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module dedupe-rules
|
|
3
|
+
* @description Removes duplicate webpack rules based on their test pattern.
|
|
4
|
+
*/
|
|
5
|
+
import { RuleSetRule } from 'webpack';
|
|
6
|
+
/**
|
|
7
|
+
* Dedupe rules (last one wins)
|
|
8
|
+
*/
|
|
9
|
+
export declare function dedupeRules(rules: RuleSetRule[]): RuleSetRule[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module dedupe-rules
|
|
4
|
+
* @description Removes duplicate webpack rules based on their test pattern.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.dedupeRules = dedupeRules;
|
|
8
|
+
/**
|
|
9
|
+
* Extracts a comparable key from a rule
|
|
10
|
+
*/
|
|
11
|
+
function getRuleKey(rule) {
|
|
12
|
+
if (rule.test instanceof RegExp) {
|
|
13
|
+
return rule.test.toString();
|
|
14
|
+
}
|
|
15
|
+
return JSON.stringify(rule.test || rule.include || rule.exclude || {});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Dedupe rules (last one wins)
|
|
19
|
+
*/
|
|
20
|
+
function dedupeRules(rules) {
|
|
21
|
+
const map = new Map();
|
|
22
|
+
for (const rule of rules) {
|
|
23
|
+
const key = getRuleKey(rule);
|
|
24
|
+
map.set(key, rule);
|
|
25
|
+
}
|
|
26
|
+
return Array.from(map.values());
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textCapitalize = exports.dedupeRules = exports.dedupePlugins = void 0;
|
|
4
|
+
var dedupe_plugins_1 = require("./dedupe-plugins");
|
|
5
|
+
Object.defineProperty(exports, "dedupePlugins", { enumerable: true, get: function () { return dedupe_plugins_1.dedupePlugins; } });
|
|
6
|
+
var dedupe_rules_1 = require("./dedupe-rules");
|
|
7
|
+
Object.defineProperty(exports, "dedupeRules", { enumerable: true, get: function () { return dedupe_rules_1.dedupeRules; } });
|
|
8
|
+
var text_capitalize_1 = require("./text-capitalize");
|
|
9
|
+
Object.defineProperty(exports, "textCapitalize", { enumerable: true, get: function () { return text_capitalize_1.textCapitalize; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function textCapitalize(value: string): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@razerspine/build",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Scalable Webpack build system for Pug, HTML, and React applications with smart hosting support",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"webpack",
|
|
7
|
+
"webpack-config",
|
|
8
|
+
"pug",
|
|
9
|
+
"react",
|
|
10
|
+
"spa",
|
|
11
|
+
"mpa",
|
|
12
|
+
"define-config",
|
|
13
|
+
"vercel",
|
|
14
|
+
"build-tool"
|
|
15
|
+
],
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"author": "Razerspine",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/Razerspine/webpack-starter-monorepo.git",
|
|
21
|
+
"directory": "packages/build"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/Razerspine/webpack-starter-monorepo/blob/main/packages/build#readme",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/Razerspine/webpack-starter-monorepo/issues"
|
|
26
|
+
},
|
|
27
|
+
"type": "commonjs",
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"types": "dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"require": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./types": {
|
|
36
|
+
"types": "./dist/types/index.d.ts",
|
|
37
|
+
"require": "./dist/types/index.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"sideEffects": false,
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=20"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist",
|
|
46
|
+
"README.md",
|
|
47
|
+
"CHANGELOG.md",
|
|
48
|
+
"LICENSE"
|
|
49
|
+
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsc -p tsconfig.json",
|
|
52
|
+
"prepublishOnly": "npm run build",
|
|
53
|
+
"test": "vitest run",
|
|
54
|
+
"test:unit": "vitest run tests/unit",
|
|
55
|
+
"test:integration": "vitest run tests/integration",
|
|
56
|
+
"test:snapshots": "vitest run tests/snapshots",
|
|
57
|
+
"test:e2e:prepare": "npm install --prefix tests/fixtures/mpa && npm install --prefix tests/fixtures/spa",
|
|
58
|
+
"test:e2e": "vitest run tests/e2e",
|
|
59
|
+
"test:e2e:full": "npm run test:e2e:prepare && npm run test:e2e"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"pug-plugin": "^5 || ^6",
|
|
63
|
+
"webpack": "^5",
|
|
64
|
+
"webpack-dev-server": "^5",
|
|
65
|
+
"html-webpack-plugin": "^5",
|
|
66
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.2"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"pug-plugin": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"html-webpack-plugin": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"@pmmmwh/react-refresh-webpack-plugin": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@types/node": "^20.11.0",
|
|
81
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
82
|
+
"html-webpack-plugin": "^5.6.6",
|
|
83
|
+
"jsdom": "^29.0.0",
|
|
84
|
+
"pug-plugin": "^6.1.0",
|
|
85
|
+
"typescript": "^5.3.3",
|
|
86
|
+
"vitest": "^4.1.0",
|
|
87
|
+
"webpack": "^5.105.0",
|
|
88
|
+
"webpack-dev-server": "^5.2.3",
|
|
89
|
+
"webpack-merge": "^5.10.0"
|
|
90
|
+
}
|
|
91
|
+
}
|