swico 2.9.0 → 3.0.0-beta.2
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/README.md +1 -1
- package/package.json +10 -23
- package/src/command/build.js +12 -11
- package/src/command/start.js +16 -40
- package/src/main-config/index.d.ts +1 -0
- package/src/main-config/index.js +9 -1
- package/src/rsbuild-config/config.base.react.d.ts +3 -0
- package/src/rsbuild-config/config.base.react.js +99 -0
- package/src/rsbuild-config/config.base.vue.d.ts +3 -0
- package/src/rsbuild-config/config.base.vue.js +99 -0
- package/src/rsbuild-config/config.dev.d.ts +3 -0
- package/src/{rspack-config/rsbpack.dev.js → rsbuild-config/config.dev.js} +53 -46
- package/src/rsbuild-config/config.prod.d.ts +3 -0
- package/src/rsbuild-config/config.prod.js +72 -0
- package/src/utils.d.ts +0 -1
- package/src/utils.js +1 -9
- package/src/rspack-config/rsbpack.dev.d.ts +0 -2
- package/src/rspack-config/rspack.base.react.d.ts +0 -100
- package/src/rspack-config/rspack.base.react.js +0 -166
- package/src/rspack-config/rspack.base.vue.d.ts +0 -135
- package/src/rspack-config/rspack.base.vue.js +0 -279
- package/src/rspack-config/rspack.prod.d.ts +0 -2
- package/src/rspack-config/rspack.prod.js +0 -128
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.default = default_1;
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const main_config_1 = require("../main-config");
|
|
18
|
-
const vue_loader_1 = require("vue-loader");
|
|
19
|
-
const core_1 = require("@rspack/core");
|
|
20
|
-
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
21
|
-
const vueStyleLoader = require.resolve('vue-style-loader');
|
|
22
|
-
const cssLoader = require.resolve('css-loader');
|
|
23
|
-
const lessLoader = require.resolve('less-loader');
|
|
24
|
-
const sassLoader = require.resolve('sass-loader');
|
|
25
|
-
const postcssLoader = require.resolve('postcss-loader');
|
|
26
|
-
function default_1(_a) {
|
|
27
|
-
return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
|
|
28
|
-
var _b, _c, _d, _e, _f;
|
|
29
|
-
const customBaseConfig = customConfig.base;
|
|
30
|
-
const getCustomAliasConfig = () => {
|
|
31
|
-
const { alias } = customBaseConfig || {};
|
|
32
|
-
const custAliasConfig = {};
|
|
33
|
-
if (alias) {
|
|
34
|
-
Object.keys(alias).forEach((key) => {
|
|
35
|
-
custAliasConfig[key] = path_1.default.join(projectPath, `/${alias[key]}`);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return custAliasConfig;
|
|
39
|
-
};
|
|
40
|
-
const publicPath = (_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) !== null && _b !== void 0 ? _b : main_config_1.initConfig.publicPath;
|
|
41
|
-
const routerBase = (_d = (_c = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _c === void 0 ? void 0 : _c.base) !== null && _d !== void 0 ? _d : main_config_1.initConfig.router.base;
|
|
42
|
-
const initialDefineVarsConfig = {
|
|
43
|
-
SWICO_ENV: JSON.stringify(env),
|
|
44
|
-
SWICO_ROUTER_BASE: JSON.stringify(routerBase),
|
|
45
|
-
SWICO_PUBLIC_PATH: JSON.stringify(publicPath),
|
|
46
|
-
SWICO_STATIC_PUBLIC_PATH: JSON.stringify(env === 'prod' ? publicPath : '/')
|
|
47
|
-
};
|
|
48
|
-
const customDefineVarsConfig = yield (0, main_config_1.getFormatDefineVars)((_e = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.define) !== null && _e !== void 0 ? _e : {});
|
|
49
|
-
return {
|
|
50
|
-
entry: entryPath,
|
|
51
|
-
output: {
|
|
52
|
-
path: path_1.default.join(projectPath, '/dist'),
|
|
53
|
-
filename: 'js/[name].[chunkhash].js',
|
|
54
|
-
chunkFilename: 'js/[name].[chunkhash].js',
|
|
55
|
-
cssFilename: 'css/[id].css',
|
|
56
|
-
cssChunkFilename: 'css/[id].css',
|
|
57
|
-
assetModuleFilename: 'assets/[name]_[id][ext]',
|
|
58
|
-
publicPath,
|
|
59
|
-
clean: true
|
|
60
|
-
},
|
|
61
|
-
target: ['web', 'es5'],
|
|
62
|
-
module: {
|
|
63
|
-
rules: [
|
|
64
|
-
{
|
|
65
|
-
test: /\.vue$/,
|
|
66
|
-
loader: require.resolve('vue-loader'),
|
|
67
|
-
exclude: /node_modules/,
|
|
68
|
-
options: {
|
|
69
|
-
experimentalInlineMatchResource: true
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
test: /\.(ts|js)$/,
|
|
74
|
-
exclude: /node_modules/,
|
|
75
|
-
use: [
|
|
76
|
-
{
|
|
77
|
-
loader: 'builtin:swc-loader',
|
|
78
|
-
options: {
|
|
79
|
-
jsc: {
|
|
80
|
-
parser: {
|
|
81
|
-
syntax: 'typescript',
|
|
82
|
-
tsx: false,
|
|
83
|
-
decorators: true,
|
|
84
|
-
dynamicImport: true
|
|
85
|
-
},
|
|
86
|
-
target: 'es2015'
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
oneOf: [
|
|
94
|
-
{
|
|
95
|
-
test: /\.css$/,
|
|
96
|
-
oneOf: [
|
|
97
|
-
{
|
|
98
|
-
resourceQuery: /module/,
|
|
99
|
-
use: [
|
|
100
|
-
vueStyleLoader,
|
|
101
|
-
{
|
|
102
|
-
loader: cssLoader,
|
|
103
|
-
options: {
|
|
104
|
-
modules: {
|
|
105
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]',
|
|
106
|
-
namedExport: false
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
loader: postcssLoader,
|
|
112
|
-
options: {
|
|
113
|
-
postcssOptions: {
|
|
114
|
-
plugins: [['autoprefixer']]
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
]
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
use: [
|
|
122
|
-
env === 'dev'
|
|
123
|
-
? vueStyleLoader
|
|
124
|
-
: core_1.CssExtractRspackPlugin.loader,
|
|
125
|
-
cssLoader,
|
|
126
|
-
{
|
|
127
|
-
loader: postcssLoader,
|
|
128
|
-
options: {
|
|
129
|
-
postcssOptions: {
|
|
130
|
-
plugins: [['autoprefixer']]
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
]
|
|
135
|
-
}
|
|
136
|
-
]
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
test: /\.less$/,
|
|
140
|
-
oneOf: [
|
|
141
|
-
{
|
|
142
|
-
resourceQuery: /module/,
|
|
143
|
-
use: [
|
|
144
|
-
vueStyleLoader,
|
|
145
|
-
{
|
|
146
|
-
loader: cssLoader,
|
|
147
|
-
options: {
|
|
148
|
-
modules: {
|
|
149
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]',
|
|
150
|
-
namedExport: false
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
loader: postcssLoader,
|
|
156
|
-
options: {
|
|
157
|
-
postcssOptions: {
|
|
158
|
-
plugins: [['autoprefixer']]
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
lessLoader
|
|
163
|
-
]
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
use: [
|
|
167
|
-
env === 'dev'
|
|
168
|
-
? vueStyleLoader
|
|
169
|
-
: core_1.CssExtractRspackPlugin.loader,
|
|
170
|
-
cssLoader,
|
|
171
|
-
{
|
|
172
|
-
loader: postcssLoader,
|
|
173
|
-
options: {
|
|
174
|
-
postcssOptions: {
|
|
175
|
-
plugins: [['autoprefixer']]
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
lessLoader
|
|
180
|
-
]
|
|
181
|
-
}
|
|
182
|
-
]
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
test: /\.scss$/,
|
|
186
|
-
oneOf: [
|
|
187
|
-
{
|
|
188
|
-
resourceQuery: /module/,
|
|
189
|
-
use: [
|
|
190
|
-
vueStyleLoader,
|
|
191
|
-
{
|
|
192
|
-
loader: cssLoader,
|
|
193
|
-
options: {
|
|
194
|
-
modules: {
|
|
195
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]',
|
|
196
|
-
namedExport: false
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
loader: postcssLoader,
|
|
202
|
-
options: {
|
|
203
|
-
postcssOptions: {
|
|
204
|
-
plugins: [['autoprefixer']]
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
sassLoader
|
|
209
|
-
]
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
use: [
|
|
213
|
-
env === 'dev'
|
|
214
|
-
? vueStyleLoader
|
|
215
|
-
: core_1.CssExtractRspackPlugin.loader,
|
|
216
|
-
cssLoader,
|
|
217
|
-
{
|
|
218
|
-
loader: postcssLoader,
|
|
219
|
-
options: {
|
|
220
|
-
postcssOptions: {
|
|
221
|
-
plugins: [['autoprefixer']]
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
sassLoader
|
|
226
|
-
]
|
|
227
|
-
}
|
|
228
|
-
]
|
|
229
|
-
}
|
|
230
|
-
]
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
test: /\.(jpg|png|gif|webp|bmp|jpeg|svg)$/,
|
|
234
|
-
type: 'asset',
|
|
235
|
-
generator: {
|
|
236
|
-
filename: 'images/[name]_[contenthash][ext]'
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
test: /\.(otf|eot|woff2?|ttf)$/i,
|
|
241
|
-
type: 'asset',
|
|
242
|
-
generator: {
|
|
243
|
-
filename: 'fonts/[name]_[contenthash][ext]'
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
test: /\.(txt|xml)$/i,
|
|
248
|
-
type: 'asset/source'
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
test: /\.html$/,
|
|
252
|
-
loader: require.resolve('html-loader')
|
|
253
|
-
}
|
|
254
|
-
]
|
|
255
|
-
},
|
|
256
|
-
resolve: {
|
|
257
|
-
extensions: ['.ts', '.js', '.vue', '.json'],
|
|
258
|
-
alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), vue: 'vue/dist/vue.esm-bundler.js', 'vue-router': path_1.default.dirname(require.resolve('vue-router')), 'swico/vue': path_1.default.join(projectPath, '/.swico/index'), swico: path_1.default.join(projectPath, '/.swico/index'), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
|
|
259
|
-
},
|
|
260
|
-
externals: customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.externals,
|
|
261
|
-
plugins: [
|
|
262
|
-
new core_1.CssExtractRspackPlugin({
|
|
263
|
-
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
264
|
-
ignoreOrder: true
|
|
265
|
-
}),
|
|
266
|
-
new vue_loader_1.VueLoaderPlugin(),
|
|
267
|
-
new core_1.DefinePlugin(Object.assign(Object.assign({ __VUE_OPTIONS_API__: true, __VUE_PROD_DEVTOOLS__: false, __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false }, initialDefineVarsConfig), customDefineVarsConfig)),
|
|
268
|
-
new html_webpack_plugin_1.default({
|
|
269
|
-
template: path_1.default.join(projectPath, '/src/index.ejs'),
|
|
270
|
-
filename: 'index.html',
|
|
271
|
-
minify: true,
|
|
272
|
-
templateParameters: initialDefineVarsConfig,
|
|
273
|
-
hash: true
|
|
274
|
-
}),
|
|
275
|
-
...((_f = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) !== null && _f !== void 0 ? _f : main_config_1.initConfig.plugins)
|
|
276
|
-
]
|
|
277
|
-
};
|
|
278
|
-
});
|
|
279
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.default = default_1;
|
|
49
|
-
const webpack_bundle_analyzer_1 = __importDefault(require("webpack-bundle-analyzer"));
|
|
50
|
-
const path_1 = __importDefault(require("path"));
|
|
51
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
52
|
-
const main_config_1 = require("../main-config");
|
|
53
|
-
const webpack_merge_1 = require("webpack-merge");
|
|
54
|
-
const core_1 = require("@rspack/core");
|
|
55
|
-
const BundleAnalyzerPlugin = webpack_bundle_analyzer_1.default.BundleAnalyzerPlugin;
|
|
56
|
-
const isAnalyze = process.env.ANALYZE === 'true';
|
|
57
|
-
function default_1(options) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
60
|
-
const { projectPath, customConfig, templateType } = options;
|
|
61
|
-
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './rspack.base.vue' : './rspack.base.react'}`).then(s => __importStar(require(s)))).default;
|
|
62
|
-
const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'prod' }));
|
|
63
|
-
const consoleAvailable = (_b = (_a = customConfig.prod) === null || _a === void 0 ? void 0 : _a.console) !== null && _b !== void 0 ? _b : main_config_1.initConfig.console;
|
|
64
|
-
const isPublicDirExist = yield fs_extra_1.default.exists(path_1.default.join(projectPath, '/public'));
|
|
65
|
-
const copyConfig = (_d = (_c = customConfig.prod) === null || _c === void 0 ? void 0 : _c.copy) !== null && _d !== void 0 ? _d : main_config_1.initConfig.copy;
|
|
66
|
-
const customDevtool = (_e = customConfig.prod.devtool) !== null && _e !== void 0 ? _e : customConfig.base.devtool;
|
|
67
|
-
return (0, webpack_merge_1.merge)(baseConfig, {
|
|
68
|
-
output: {
|
|
69
|
-
cssFilename: 'css/[name].[contenthash].css',
|
|
70
|
-
cssChunkFilename: 'css/[name].[contenthash].css'
|
|
71
|
-
},
|
|
72
|
-
performance: {
|
|
73
|
-
hints: false
|
|
74
|
-
},
|
|
75
|
-
mode: 'production',
|
|
76
|
-
devtool: customDevtool !== null && customDevtool !== void 0 ? customDevtool : undefined,
|
|
77
|
-
optimization: {
|
|
78
|
-
runtimeChunk: true,
|
|
79
|
-
minimize: true,
|
|
80
|
-
minimizer: [
|
|
81
|
-
new core_1.rspack.SwcJsMinimizerRspackPlugin({
|
|
82
|
-
minimizerOptions: {
|
|
83
|
-
minify: true,
|
|
84
|
-
mangle: true,
|
|
85
|
-
compress: {
|
|
86
|
-
passes: 2,
|
|
87
|
-
drop_console: !consoleAvailable
|
|
88
|
-
},
|
|
89
|
-
format: {
|
|
90
|
-
comments: false
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}),
|
|
94
|
-
new core_1.rspack.LightningCssMinimizerRspackPlugin({})
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
plugins: [
|
|
98
|
-
...(isPublicDirExist || copyConfig.length > 0
|
|
99
|
-
? [
|
|
100
|
-
new core_1.rspack.CopyRspackPlugin({
|
|
101
|
-
patterns: [
|
|
102
|
-
...(isPublicDirExist ? [path_1.default.join(projectPath, '/public')] : []),
|
|
103
|
-
...(copyConfig || [])
|
|
104
|
-
]
|
|
105
|
-
})
|
|
106
|
-
]
|
|
107
|
-
: []),
|
|
108
|
-
...(isAnalyze
|
|
109
|
-
? [
|
|
110
|
-
new BundleAnalyzerPlugin({
|
|
111
|
-
analyzerMode: 'server',
|
|
112
|
-
analyzerHost: '127.0.0.1',
|
|
113
|
-
analyzerPort: 'auto',
|
|
114
|
-
reportFilename: 'report.html',
|
|
115
|
-
defaultSizes: 'stat',
|
|
116
|
-
openAnalyzer: true,
|
|
117
|
-
generateStatsFile: false,
|
|
118
|
-
statsFilename: 'analyze.json',
|
|
119
|
-
statsOptions: null,
|
|
120
|
-
logLevel: 'info'
|
|
121
|
-
})
|
|
122
|
-
]
|
|
123
|
-
: []),
|
|
124
|
-
...((_g = (_f = customConfig.prod) === null || _f === void 0 ? void 0 : _f.plugins) !== null && _g !== void 0 ? _g : [])
|
|
125
|
-
]
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
}
|