@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,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.PugTemplatesPlugin = void 0;
|
|
40
|
+
const pug_plugin_1 = __importDefault(require("pug-plugin"));
|
|
41
|
+
const fs = __importStar(require("node:fs"));
|
|
42
|
+
const path_1 = __importDefault(require("path"));
|
|
43
|
+
class PugTemplatesPlugin {
|
|
44
|
+
constructor(options) {
|
|
45
|
+
this.entry = path_1.default.resolve(options.entry);
|
|
46
|
+
this.mode = options.mode;
|
|
47
|
+
this.appType = options.appType;
|
|
48
|
+
this.validate();
|
|
49
|
+
}
|
|
50
|
+
validate() {
|
|
51
|
+
if (!fs.existsSync(this.entry)) {
|
|
52
|
+
throw new Error(`[build] Templates entry not found: ${this.entry}`);
|
|
53
|
+
}
|
|
54
|
+
const stats = fs.statSync(this.entry);
|
|
55
|
+
if (this.appType === 'spa' && !stats.isFile()) {
|
|
56
|
+
throw new Error(`[build] SPA requires a single pug file as templates.entry`);
|
|
57
|
+
}
|
|
58
|
+
if (this.appType === 'mpa' && !stats.isDirectory()) {
|
|
59
|
+
throw new Error(`[build] MPA requires templates.entry to be a directory`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
apply(compiler) {
|
|
63
|
+
const pluginEntry = this.appType === 'spa' ? { index: this.entry } : this.entry;
|
|
64
|
+
const pugPlugin = new pug_plugin_1.default({
|
|
65
|
+
entry: pluginEntry,
|
|
66
|
+
filename: ({ chunk }) => {
|
|
67
|
+
if (this.appType === 'spa') {
|
|
68
|
+
return 'index.html';
|
|
69
|
+
}
|
|
70
|
+
let [name] = chunk.name.split('/');
|
|
71
|
+
if (name === 'home') {
|
|
72
|
+
name = 'index';
|
|
73
|
+
}
|
|
74
|
+
return `${name}.html`;
|
|
75
|
+
},
|
|
76
|
+
js: {
|
|
77
|
+
filename: this.mode === 'production'
|
|
78
|
+
? 'js/[name].[contenthash:8].js'
|
|
79
|
+
: 'js/[name].js',
|
|
80
|
+
},
|
|
81
|
+
css: {
|
|
82
|
+
filename: this.mode === 'production'
|
|
83
|
+
? 'css/[name].[contenthash:8].css'
|
|
84
|
+
: 'css/[name].css',
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
pugPlugin.apply(compiler);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.PugTemplatesPlugin = PugTemplatesPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { reactPreset } from './react-preset';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reactPreset = void 0;
|
|
4
|
+
var react_preset_1 = require("./react-preset");
|
|
5
|
+
Object.defineProperty(exports, "reactPreset", { enumerable: true, get: function () { return react_preset_1.reactPreset; } });
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module react-preset
|
|
3
|
+
* @description Production-ready React preset for @razerspine/build.
|
|
4
|
+
*
|
|
5
|
+
* Provides a modern React development experience using:
|
|
6
|
+
* - Babel (no ts-loader)
|
|
7
|
+
* - Automatic JSX runtime (react/jsx-runtime)
|
|
8
|
+
* - TypeScript support (.ts / .tsx)
|
|
9
|
+
* - React Fast Refresh (development only)
|
|
10
|
+
*
|
|
11
|
+
* ---
|
|
12
|
+
* Behavior:
|
|
13
|
+
*
|
|
14
|
+
* - Automatically sets `templates.type = 'none'` if not defined
|
|
15
|
+
* - Warns if incompatible template engines are used (pug/html)
|
|
16
|
+
* - Injects Babel-based React pipeline
|
|
17
|
+
* - Adds React Refresh plugin in development mode (if installed)
|
|
18
|
+
*
|
|
19
|
+
* ---
|
|
20
|
+
* Requirements (must be installed in user project):
|
|
21
|
+
*
|
|
22
|
+
* ```bash
|
|
23
|
+
* npm install -D \
|
|
24
|
+
* babel-loader \
|
|
25
|
+
* @babel/core \
|
|
26
|
+
* @babel/preset-env \
|
|
27
|
+
* @babel/preset-react \
|
|
28
|
+
* @babel/preset-typescript \
|
|
29
|
+
* @pmmmwh/react-refresh-webpack-plugin \
|
|
30
|
+
* react-refresh
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* ---
|
|
34
|
+
* Example:
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* import {defineConfig, reactPreset} from '@razerspine/build';
|
|
38
|
+
*
|
|
39
|
+
* export default defineConfig({
|
|
40
|
+
* mode: 'development',
|
|
41
|
+
* scripts: 'ts',
|
|
42
|
+
* styles: 'scss',
|
|
43
|
+
* presets: [reactPreset()]
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
import { BuildPluginType } from '../../types';
|
|
48
|
+
/**
|
|
49
|
+
* Options for React preset
|
|
50
|
+
*/
|
|
51
|
+
type ReactPresetOptions = {
|
|
52
|
+
/**
|
|
53
|
+
* Enables TypeScript support (.ts / .tsx)
|
|
54
|
+
*
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
typescript?: boolean;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* React preset factory
|
|
61
|
+
*
|
|
62
|
+
* @param options - React preset configuration
|
|
63
|
+
* @returns Build plugin instance
|
|
64
|
+
*/
|
|
65
|
+
export declare function reactPreset(options?: ReactPresetOptions): BuildPluginType;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module react-preset
|
|
4
|
+
* @description Production-ready React preset for @razerspine/build.
|
|
5
|
+
*
|
|
6
|
+
* Provides a modern React development experience using:
|
|
7
|
+
* - Babel (no ts-loader)
|
|
8
|
+
* - Automatic JSX runtime (react/jsx-runtime)
|
|
9
|
+
* - TypeScript support (.ts / .tsx)
|
|
10
|
+
* - React Fast Refresh (development only)
|
|
11
|
+
*
|
|
12
|
+
* ---
|
|
13
|
+
* Behavior:
|
|
14
|
+
*
|
|
15
|
+
* - Automatically sets `templates.type = 'none'` if not defined
|
|
16
|
+
* - Warns if incompatible template engines are used (pug/html)
|
|
17
|
+
* - Injects Babel-based React pipeline
|
|
18
|
+
* - Adds React Refresh plugin in development mode (if installed)
|
|
19
|
+
*
|
|
20
|
+
* ---
|
|
21
|
+
* Requirements (must be installed in user project):
|
|
22
|
+
*
|
|
23
|
+
* ```bash
|
|
24
|
+
* npm install -D \
|
|
25
|
+
* babel-loader \
|
|
26
|
+
* @babel/core \
|
|
27
|
+
* @babel/preset-env \
|
|
28
|
+
* @babel/preset-react \
|
|
29
|
+
* @babel/preset-typescript \
|
|
30
|
+
* @pmmmwh/react-refresh-webpack-plugin \
|
|
31
|
+
* react-refresh
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* ---
|
|
35
|
+
* Example:
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* import {defineConfig, reactPreset} from '@razerspine/build';
|
|
39
|
+
*
|
|
40
|
+
* export default defineConfig({
|
|
41
|
+
* mode: 'development',
|
|
42
|
+
* scripts: 'ts',
|
|
43
|
+
* styles: 'scss',
|
|
44
|
+
* presets: [reactPreset()]
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.reactPreset = reactPreset;
|
|
50
|
+
/**
|
|
51
|
+
* React preset factory
|
|
52
|
+
*
|
|
53
|
+
* @param options - React preset configuration
|
|
54
|
+
* @returns Build plugin instance
|
|
55
|
+
*/
|
|
56
|
+
function reactPreset(options = {}) {
|
|
57
|
+
var _a;
|
|
58
|
+
const useTS = (_a = options.typescript) !== null && _a !== void 0 ? _a : true;
|
|
59
|
+
return {
|
|
60
|
+
name: 'react-preset',
|
|
61
|
+
/**
|
|
62
|
+
* Setup phase
|
|
63
|
+
*
|
|
64
|
+
* - Ensures templates are disabled by default (React does not use Pug/HTML templates)
|
|
65
|
+
* - Emits warning if user explicitly enables incompatible template engines
|
|
66
|
+
*/
|
|
67
|
+
setup({ options }) {
|
|
68
|
+
var _a;
|
|
69
|
+
const type = (_a = options.templates) === null || _a === void 0 ? void 0 : _a.type;
|
|
70
|
+
// Default to "none" if not explicitly defined
|
|
71
|
+
if (!type) {
|
|
72
|
+
options.templates = { type: 'none' };
|
|
73
|
+
}
|
|
74
|
+
// Warn about potential conflicts
|
|
75
|
+
if (type === 'pug' || type === 'html') {
|
|
76
|
+
console.warn(`[react-preset] templates.type='${type}' may conflict with React setup.`);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* Base configuration extension
|
|
81
|
+
*
|
|
82
|
+
* Injects:
|
|
83
|
+
* - entry (if not provided)
|
|
84
|
+
* - resolve.extensions
|
|
85
|
+
* - Babel loader rule for React
|
|
86
|
+
* - React Refresh plugin (development only)
|
|
87
|
+
*/
|
|
88
|
+
applyBase(config) {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
const isDev = config.mode === 'development';
|
|
91
|
+
/**
|
|
92
|
+
* Entry
|
|
93
|
+
*/
|
|
94
|
+
if (!config.entry) {
|
|
95
|
+
config.entry = useTS ? './src/main.tsx' : './src/main.jsx';
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Resolve extensions
|
|
99
|
+
*/
|
|
100
|
+
config.resolve = {
|
|
101
|
+
...config.resolve,
|
|
102
|
+
extensions: Array.from(new Set([
|
|
103
|
+
...(((_a = config.resolve) === null || _a === void 0 ? void 0 : _a.extensions) || []),
|
|
104
|
+
'.jsx',
|
|
105
|
+
'.js',
|
|
106
|
+
...(useTS ? ['.tsx', '.ts'] : []),
|
|
107
|
+
])),
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Babel loader configuration
|
|
111
|
+
*/
|
|
112
|
+
const babelLoader = {
|
|
113
|
+
loader: 'babel-loader',
|
|
114
|
+
options: {
|
|
115
|
+
cacheDirectory: true,
|
|
116
|
+
presets: [
|
|
117
|
+
[
|
|
118
|
+
'@babel/preset-env',
|
|
119
|
+
{
|
|
120
|
+
targets: 'defaults',
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
'@babel/preset-react',
|
|
125
|
+
{
|
|
126
|
+
runtime: 'automatic',
|
|
127
|
+
development: isDev,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
...(useTS ? ['@babel/preset-typescript'] : []),
|
|
131
|
+
],
|
|
132
|
+
plugins: isDev ? ['react-refresh/babel'] : [],
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
const reactRule = {
|
|
136
|
+
test: useTS ? /\.(ts|tsx)$/ : /\.(js|jsx)$/,
|
|
137
|
+
exclude: /node_modules/,
|
|
138
|
+
use: [babelLoader],
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Prevent rule duplication
|
|
142
|
+
*/
|
|
143
|
+
const existingRules = ((_b = config.module) === null || _b === void 0 ? void 0 : _b.rules) || [];
|
|
144
|
+
const hasReactRule = existingRules.some(rule => {
|
|
145
|
+
var _a;
|
|
146
|
+
return (rule &&
|
|
147
|
+
typeof rule === 'object' &&
|
|
148
|
+
'test' in rule &&
|
|
149
|
+
((_a = rule.test) === null || _a === void 0 ? void 0 : _a.toString().includes(useTS ? 'tsx' : 'jsx')));
|
|
150
|
+
});
|
|
151
|
+
if (!hasReactRule) {
|
|
152
|
+
config.module = {
|
|
153
|
+
...config.module,
|
|
154
|
+
rules: [...existingRules, reactRule],
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* React Fast Refresh (development only)
|
|
159
|
+
*/
|
|
160
|
+
if (isDev) {
|
|
161
|
+
try {
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
163
|
+
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
164
|
+
const plugins = config.plugins || [];
|
|
165
|
+
const hasPlugin = plugins.some(p => {
|
|
166
|
+
var _a;
|
|
167
|
+
return p &&
|
|
168
|
+
typeof p === 'object' &&
|
|
169
|
+
((_a = p.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'ReactRefreshPlugin';
|
|
170
|
+
});
|
|
171
|
+
if (!hasPlugin) {
|
|
172
|
+
plugins.push(new ReactRefreshPlugin());
|
|
173
|
+
config.plugins = plugins;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
/**
|
|
178
|
+
* Do not throw — keep build stable
|
|
179
|
+
*/
|
|
180
|
+
console.warn('\n[react-preset] Warning: "@pmmmwh/react-refresh-webpack-plugin" not found.\n' +
|
|
181
|
+
'Fast Refresh is disabled. Install it to enable better DX.\n');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
/**
|
|
186
|
+
* Development-specific configuration
|
|
187
|
+
*/
|
|
188
|
+
applyDev(config) {
|
|
189
|
+
config.devtool = 'eval-source-map';
|
|
190
|
+
},
|
|
191
|
+
/**
|
|
192
|
+
* Production-specific configuration
|
|
193
|
+
*/
|
|
194
|
+
applyProd(config) {
|
|
195
|
+
config.devtool = 'source-map';
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare function assetsRule(): {
|
|
2
|
+
oneOf: ({
|
|
3
|
+
test: RegExp;
|
|
4
|
+
type: string;
|
|
5
|
+
include: RegExp;
|
|
6
|
+
generator: {
|
|
7
|
+
filename: string;
|
|
8
|
+
};
|
|
9
|
+
exclude?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
test: RegExp;
|
|
12
|
+
exclude: RegExp;
|
|
13
|
+
type: string;
|
|
14
|
+
generator: {
|
|
15
|
+
filename: string;
|
|
16
|
+
};
|
|
17
|
+
include?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
test: RegExp;
|
|
20
|
+
type: string;
|
|
21
|
+
generator: {
|
|
22
|
+
filename: string;
|
|
23
|
+
};
|
|
24
|
+
include?: undefined;
|
|
25
|
+
exclude?: undefined;
|
|
26
|
+
})[];
|
|
27
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assetsRule = assetsRule;
|
|
4
|
+
function assetsRule() {
|
|
5
|
+
return {
|
|
6
|
+
oneOf: [
|
|
7
|
+
{
|
|
8
|
+
test: /\.(woff(2)?|ttf|otf|eot|svg)$/i,
|
|
9
|
+
type: 'asset/resource',
|
|
10
|
+
include: /assets\/fonts|node_modules/,
|
|
11
|
+
generator: {
|
|
12
|
+
filename: 'fonts/[name][ext][query]',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
test: /\.(png|jpe?g|svg|webp|ico)$/i,
|
|
17
|
+
exclude: /assets\/fonts/,
|
|
18
|
+
type: 'asset/resource',
|
|
19
|
+
generator: {
|
|
20
|
+
filename: 'img/[name].[hash:8][ext]',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
test: /\.webmanifest$/i,
|
|
25
|
+
type: 'asset/resource',
|
|
26
|
+
generator: {
|
|
27
|
+
filename: 'favicons/[name][ext]',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stylesRule = exports.scriptsRule = exports.pugRule = exports.assetsRule = void 0;
|
|
4
|
+
var assets_rule_1 = require("./assets-rule");
|
|
5
|
+
Object.defineProperty(exports, "assetsRule", { enumerable: true, get: function () { return assets_rule_1.assetsRule; } });
|
|
6
|
+
var pug_rule_1 = require("./pug-rule");
|
|
7
|
+
Object.defineProperty(exports, "pugRule", { enumerable: true, get: function () { return pug_rule_1.pugRule; } });
|
|
8
|
+
var scripts_rule_1 = require("./scripts-rule");
|
|
9
|
+
Object.defineProperty(exports, "scriptsRule", { enumerable: true, get: function () { return scripts_rule_1.scriptsRule; } });
|
|
10
|
+
var styles_rule_1 = require("./styles-rule");
|
|
11
|
+
Object.defineProperty(exports, "stylesRule", { enumerable: true, get: function () { return styles_rule_1.stylesRule; } });
|
|
@@ -0,0 +1,27 @@
|
|
|
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.pugRule = pugRule;
|
|
7
|
+
const pug_plugin_1 = __importDefault(require("pug-plugin"));
|
|
8
|
+
function pugRule() {
|
|
9
|
+
return {
|
|
10
|
+
test: /\.pug$/,
|
|
11
|
+
oneOf: [
|
|
12
|
+
{
|
|
13
|
+
issuer: /\.(js|ts|tsx|jsx)$/,
|
|
14
|
+
loader: pug_plugin_1.default.loader,
|
|
15
|
+
options: {
|
|
16
|
+
method: 'compile',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
loader: pug_plugin_1.default.loader,
|
|
21
|
+
options: {
|
|
22
|
+
method: 'render',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ConfigOptionType } from '../types';
|
|
2
|
+
export declare function scriptsRule(env: ConfigOptionType): {
|
|
3
|
+
test: RegExp;
|
|
4
|
+
exclude: RegExp;
|
|
5
|
+
use: {
|
|
6
|
+
loader: string;
|
|
7
|
+
options: {
|
|
8
|
+
transpileOnly: boolean;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
} | {
|
|
12
|
+
test: RegExp;
|
|
13
|
+
exclude: RegExp;
|
|
14
|
+
use: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scriptsRule = scriptsRule;
|
|
4
|
+
function scriptsRule(env) {
|
|
5
|
+
if (env.scripts === 'ts') {
|
|
6
|
+
return {
|
|
7
|
+
test: /\.ts$/,
|
|
8
|
+
exclude: /node_modules/,
|
|
9
|
+
use: {
|
|
10
|
+
loader: 'ts-loader',
|
|
11
|
+
options: {
|
|
12
|
+
transpileOnly: env.mode === 'development',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
test: /\.m?js$/,
|
|
19
|
+
exclude: /node_modules/,
|
|
20
|
+
use: 'babel-loader',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ConfigOptionType } from '../types';
|
|
2
|
+
export declare function stylesRule(env: ConfigOptionType): {
|
|
3
|
+
test: RegExp;
|
|
4
|
+
use: (string | {
|
|
5
|
+
loader: string;
|
|
6
|
+
options: {
|
|
7
|
+
postcssOptions: {
|
|
8
|
+
plugins: string[];
|
|
9
|
+
};
|
|
10
|
+
lessOptions?: undefined;
|
|
11
|
+
};
|
|
12
|
+
} | {
|
|
13
|
+
loader: string;
|
|
14
|
+
options: {
|
|
15
|
+
lessOptions: {
|
|
16
|
+
javascriptEnabled: boolean;
|
|
17
|
+
};
|
|
18
|
+
postcssOptions?: undefined;
|
|
19
|
+
};
|
|
20
|
+
})[];
|
|
21
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stylesRule = stylesRule;
|
|
4
|
+
function stylesRule(env) {
|
|
5
|
+
const isLess = env.styles === 'less';
|
|
6
|
+
return {
|
|
7
|
+
test: isLess ? /\.(css|less)$/ : /\.(css|scss|sass)$/,
|
|
8
|
+
use: [
|
|
9
|
+
'css-loader',
|
|
10
|
+
{
|
|
11
|
+
loader: 'postcss-loader',
|
|
12
|
+
options: {
|
|
13
|
+
postcssOptions: {
|
|
14
|
+
plugins: ['autoprefixer']
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
isLess
|
|
19
|
+
? {
|
|
20
|
+
loader: 'less-loader',
|
|
21
|
+
options: {
|
|
22
|
+
lessOptions: { javascriptEnabled: true }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
: 'sass-loader'
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type AppType = 'mpa' | 'spa';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Configuration } from 'webpack';
|
|
2
|
+
import { NormalizedCoreOptions } from '../options';
|
|
3
|
+
export type BuildContextType = {
|
|
4
|
+
options: NormalizedCoreOptions;
|
|
5
|
+
};
|
|
6
|
+
export type BuildPluginType = {
|
|
7
|
+
name: string;
|
|
8
|
+
/**
|
|
9
|
+
* Runs once during base config creation
|
|
10
|
+
*/
|
|
11
|
+
setup?: (ctx: BuildContextType) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Extends base config
|
|
14
|
+
*/
|
|
15
|
+
applyBase?: (config: Configuration) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Extends dev config
|
|
18
|
+
*/
|
|
19
|
+
applyDev?: (config: Configuration) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Extends production config
|
|
22
|
+
*/
|
|
23
|
+
applyProd?: (config: Configuration) => void;
|
|
24
|
+
};
|