swico 1.7.3 → 2.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/package.json +7 -13
- package/src/bin.js +6 -6
- package/src/command/build.js +33 -73
- package/src/command/start.js +99 -191
- package/src/config/rsbpack.dev.js +104 -0
- package/src/config/{webpack.base.react.d.ts → rspack.base.react.d.ts} +13 -3
- package/src/config/rspack.base.react.js +193 -0
- package/src/config/{webpack.base.vue.d.ts → rspack.base.vue.d.ts} +13 -1
- package/src/config/rspack.base.vue.js +282 -0
- package/src/config/rspack.prod.js +123 -0
- package/src/index.js +3 -5
- package/src/index.react.js +5 -10
- package/src/index.vue.js +4 -6
- package/src/project-path/.swico-react/$env/history.js +65 -66
- package/src/project-path/.swico-react/$env/index.js +29 -47
- package/src/project-path/.swico-react/loading.js +1 -1
- package/src/project-path/.swico-react/react-hooks.js +24 -37
- package/src/project-path/.swico-vue/$env/history.js +25 -36
- package/src/project-path/.swico-vue/$env/index.js +7 -7
- package/src/project-path/.swico-vue/Container.js +1 -1
- package/src/project-path/.swico-vue/vue-hooks.js +17 -28
- package/src/project-path/src/layout/Layout.js +1 -1
- package/src/project-path/src/layout/index.js +3 -3
- package/src/task.js +13 -58
- package/src/utils/config.js +185 -349
- package/src/utils/tools.js +103 -199
- package/src/config/webpack.base.react.js +0 -315
- package/src/config/webpack.base.vue.js +0 -338
- package/src/config/webpack.dev.js +0 -159
- package/src/config/webpack.prod.js +0 -193
- /package/src/config/{webpack.dev.d.ts → rsbpack.dev.d.ts} +0 -0
- /package/src/config/{webpack.prod.d.ts → rspack.prod.d.ts} +0 -0
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
-
};
|
|
58
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
|
-
};
|
|
61
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
var path_1 = __importDefault(require("path"));
|
|
63
|
-
var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
64
|
-
var config_1 = require("../utils/config");
|
|
65
|
-
var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
66
|
-
var webpack_1 = __importDefault(require("webpack"));
|
|
67
|
-
var styleLoader = require.resolve('style-loader');
|
|
68
|
-
var cssLoader = require.resolve('css-loader');
|
|
69
|
-
var lessLoader = require.resolve('less-loader');
|
|
70
|
-
var sassLoader = require.resolve('sass-loader');
|
|
71
|
-
var postcssLoader = require.resolve('postcss-loader');
|
|
72
|
-
function default_1(_a) {
|
|
73
|
-
var _b, _c, _d;
|
|
74
|
-
var projectPath = _a.projectPath, entryPath = _a.entryPath, env = _a.env, customConfig = _a.customConfig;
|
|
75
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
-
var customBaseConfig, getCustomAliasConfig, publicPath, routerBase, basicPlugins, defineConfigData, formatObj;
|
|
77
|
-
return __generator(this, function (_e) {
|
|
78
|
-
switch (_e.label) {
|
|
79
|
-
case 0:
|
|
80
|
-
customBaseConfig = customConfig.base;
|
|
81
|
-
getCustomAliasConfig = function () {
|
|
82
|
-
var alias = (customBaseConfig || {}).alias;
|
|
83
|
-
var custAliasConfig = {};
|
|
84
|
-
if (alias) {
|
|
85
|
-
Object.keys(alias).forEach(function (key) {
|
|
86
|
-
custAliasConfig[key] = path_1.default.join(projectPath, "/".concat(alias[key]));
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
return custAliasConfig;
|
|
90
|
-
};
|
|
91
|
-
publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
|
|
92
|
-
routerBase = ((_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _b === void 0 ? void 0 : _b.base) || config_1.initConfig.router.base;
|
|
93
|
-
basicPlugins = [];
|
|
94
|
-
defineConfigData = (_d = (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _c === void 0 ? void 0 : _c.define) !== null && _d !== void 0 ? _d : {};
|
|
95
|
-
return [4, (0, config_1.getFormatDefineVars)(defineConfigData)];
|
|
96
|
-
case 1:
|
|
97
|
-
formatObj = _e.sent();
|
|
98
|
-
if (Object.keys(formatObj).length !== 0) {
|
|
99
|
-
basicPlugins.push(new webpack_1.default.DefinePlugin(formatObj));
|
|
100
|
-
}
|
|
101
|
-
return [2, {
|
|
102
|
-
entry: entryPath,
|
|
103
|
-
output: {
|
|
104
|
-
path: path_1.default.join(projectPath, '/dist'),
|
|
105
|
-
filename: 'js/[name].[chunkhash].js',
|
|
106
|
-
assetModuleFilename: 'assets/[name]_[chunkhash][ext]',
|
|
107
|
-
publicPath: publicPath,
|
|
108
|
-
clean: true
|
|
109
|
-
},
|
|
110
|
-
target: ['web', 'es5'],
|
|
111
|
-
cache: {
|
|
112
|
-
type: 'filesystem'
|
|
113
|
-
},
|
|
114
|
-
module: {
|
|
115
|
-
rules: [
|
|
116
|
-
{
|
|
117
|
-
test: /\.(tsx|ts|jsx)$/,
|
|
118
|
-
exclude: /node_modules/,
|
|
119
|
-
use: [
|
|
120
|
-
{
|
|
121
|
-
loader: require.resolve('swc-loader'),
|
|
122
|
-
options: {
|
|
123
|
-
jsc: {
|
|
124
|
-
parser: {
|
|
125
|
-
syntax: 'typescript',
|
|
126
|
-
tsx: true,
|
|
127
|
-
decorators: true,
|
|
128
|
-
dynamicImport: true
|
|
129
|
-
},
|
|
130
|
-
transform: {
|
|
131
|
-
react: {
|
|
132
|
-
runtime: 'automatic',
|
|
133
|
-
useBuiltins: true,
|
|
134
|
-
importSource: 'react'
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
target: 'es2015'
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
]
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
oneOf: [
|
|
145
|
-
{
|
|
146
|
-
test: /\.module\.css$/,
|
|
147
|
-
use: [
|
|
148
|
-
env === 'dev' ? styleLoader : mini_css_extract_plugin_1.default.loader,
|
|
149
|
-
{
|
|
150
|
-
loader: cssLoader,
|
|
151
|
-
options: {
|
|
152
|
-
modules: {
|
|
153
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
loader: postcssLoader,
|
|
159
|
-
options: {
|
|
160
|
-
postcssOptions: {
|
|
161
|
-
plugins: [['autoprefixer']]
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
test: /\.css$/,
|
|
169
|
-
use: [
|
|
170
|
-
env === 'dev' ? styleLoader : mini_css_extract_plugin_1.default.loader,
|
|
171
|
-
cssLoader,
|
|
172
|
-
{
|
|
173
|
-
loader: postcssLoader,
|
|
174
|
-
options: {
|
|
175
|
-
postcssOptions: {
|
|
176
|
-
plugins: [['autoprefixer']]
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
]
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
test: /\.module\.less$/,
|
|
184
|
-
use: [
|
|
185
|
-
env === 'dev' ? styleLoader : mini_css_extract_plugin_1.default.loader,
|
|
186
|
-
{
|
|
187
|
-
loader: cssLoader,
|
|
188
|
-
options: {
|
|
189
|
-
modules: {
|
|
190
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
loader: postcssLoader,
|
|
196
|
-
options: {
|
|
197
|
-
postcssOptions: {
|
|
198
|
-
plugins: [['postcss-preset-env', 'autoprefixer']]
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
lessLoader
|
|
203
|
-
]
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
test: /\.less$/,
|
|
207
|
-
use: [
|
|
208
|
-
env === 'dev' ? styleLoader : mini_css_extract_plugin_1.default.loader,
|
|
209
|
-
cssLoader,
|
|
210
|
-
{
|
|
211
|
-
loader: postcssLoader,
|
|
212
|
-
options: {
|
|
213
|
-
postcssOptions: {
|
|
214
|
-
plugins: [['autoprefixer']]
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
lessLoader
|
|
219
|
-
]
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
test: /\.module\.scss$/,
|
|
223
|
-
use: [
|
|
224
|
-
env === 'dev' ? styleLoader : mini_css_extract_plugin_1.default.loader,
|
|
225
|
-
{
|
|
226
|
-
loader: cssLoader,
|
|
227
|
-
options: {
|
|
228
|
-
modules: {
|
|
229
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
loader: postcssLoader,
|
|
235
|
-
options: {
|
|
236
|
-
postcssOptions: {
|
|
237
|
-
plugins: [['postcss-preset-env', 'autoprefixer']]
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
sassLoader
|
|
242
|
-
]
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
test: /\.scss$/,
|
|
246
|
-
use: [
|
|
247
|
-
env === 'dev' ? styleLoader : mini_css_extract_plugin_1.default.loader,
|
|
248
|
-
cssLoader,
|
|
249
|
-
{
|
|
250
|
-
loader: postcssLoader,
|
|
251
|
-
options: {
|
|
252
|
-
postcssOptions: {
|
|
253
|
-
plugins: [['autoprefixer']]
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
lessLoader
|
|
258
|
-
]
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
test: /\.(jpg|png|gif|webp|bmp|jpeg|svg)$/,
|
|
262
|
-
type: 'asset',
|
|
263
|
-
generator: {
|
|
264
|
-
filename: 'images/[name]_[contenthash][ext]'
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
test: /\.(otf|eot|woff2?|ttf)$/i,
|
|
269
|
-
type: 'asset',
|
|
270
|
-
generator: {
|
|
271
|
-
filename: 'fonts/[name]_[contenthash][ext]'
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
test: /\.(txt|xml)$/i,
|
|
276
|
-
type: 'asset/source'
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
test: /\.html$/,
|
|
280
|
-
loader: require.resolve('html-loader')
|
|
281
|
-
}
|
|
282
|
-
]
|
|
283
|
-
}
|
|
284
|
-
]
|
|
285
|
-
},
|
|
286
|
-
resolve: {
|
|
287
|
-
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
288
|
-
alias: __assign({ '@': path_1.default.join(projectPath, '/src'), 'react-router-dom': path_1.default.dirname(require.resolve('react-router-dom')), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
|
|
289
|
-
},
|
|
290
|
-
externals: customConfig.base.externals,
|
|
291
|
-
plugins: __spreadArray(__spreadArray(__spreadArray([], basicPlugins, true), [
|
|
292
|
-
new html_webpack_plugin_1.default({
|
|
293
|
-
template: path_1.default.join(projectPath, '/src/index.ejs'),
|
|
294
|
-
filename: 'index.html',
|
|
295
|
-
minify: {
|
|
296
|
-
collapseWhitespace: true,
|
|
297
|
-
removeAttributeQuotes: true
|
|
298
|
-
},
|
|
299
|
-
templateParameters: {
|
|
300
|
-
publicPath: publicPath,
|
|
301
|
-
routerBase: routerBase
|
|
302
|
-
},
|
|
303
|
-
hash: true
|
|
304
|
-
}),
|
|
305
|
-
new mini_css_extract_plugin_1.default({
|
|
306
|
-
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
307
|
-
ignoreOrder: true
|
|
308
|
-
})
|
|
309
|
-
], false), ((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins), true)
|
|
310
|
-
}];
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
exports.default = default_1;
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
-
};
|
|
58
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
|
-
};
|
|
61
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
var path_1 = __importDefault(require("path"));
|
|
63
|
-
var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
64
|
-
var config_1 = require("../utils/config");
|
|
65
|
-
var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
66
|
-
var webpack_1 = __importDefault(require("webpack"));
|
|
67
|
-
var vue_loader_1 = require("vue-loader");
|
|
68
|
-
var vueStyleLoader = require.resolve('vue-style-loader');
|
|
69
|
-
var cssLoader = require.resolve('css-loader');
|
|
70
|
-
var lessLoader = require.resolve('less-loader');
|
|
71
|
-
var sassLoader = require.resolve('sass-loader');
|
|
72
|
-
var postcssLoader = require.resolve('postcss-loader');
|
|
73
|
-
function default_1(_a) {
|
|
74
|
-
var _b, _c, _d;
|
|
75
|
-
var projectPath = _a.projectPath, entryPath = _a.entryPath, env = _a.env, customConfig = _a.customConfig;
|
|
76
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
-
var customBaseConfig, getCustomAliasConfig, publicPath, routerBase, basicPlugins, defineConfigData, formatObj;
|
|
78
|
-
return __generator(this, function (_e) {
|
|
79
|
-
switch (_e.label) {
|
|
80
|
-
case 0:
|
|
81
|
-
customBaseConfig = customConfig.base;
|
|
82
|
-
getCustomAliasConfig = function () {
|
|
83
|
-
var alias = (customBaseConfig || {}).alias;
|
|
84
|
-
var custAliasConfig = {};
|
|
85
|
-
if (alias) {
|
|
86
|
-
Object.keys(alias).forEach(function (key) {
|
|
87
|
-
custAliasConfig[key] = path_1.default.join(projectPath, "/".concat(alias[key]));
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return custAliasConfig;
|
|
91
|
-
};
|
|
92
|
-
publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
|
|
93
|
-
routerBase = ((_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _b === void 0 ? void 0 : _b.base) || config_1.initConfig.router.base;
|
|
94
|
-
basicPlugins = [];
|
|
95
|
-
defineConfigData = (_d = (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _c === void 0 ? void 0 : _c.define) !== null && _d !== void 0 ? _d : {};
|
|
96
|
-
return [4, (0, config_1.getFormatDefineVars)(defineConfigData)];
|
|
97
|
-
case 1:
|
|
98
|
-
formatObj = _e.sent();
|
|
99
|
-
if (Object.keys(formatObj).length !== 0) {
|
|
100
|
-
basicPlugins.push(new webpack_1.default.DefinePlugin(formatObj));
|
|
101
|
-
}
|
|
102
|
-
return [2, {
|
|
103
|
-
entry: entryPath,
|
|
104
|
-
output: {
|
|
105
|
-
path: path_1.default.join(projectPath, '/dist'),
|
|
106
|
-
filename: 'js/[name].[chunkhash].js',
|
|
107
|
-
assetModuleFilename: 'assets/[name]_[chunkhash][ext]',
|
|
108
|
-
publicPath: publicPath,
|
|
109
|
-
clean: true
|
|
110
|
-
},
|
|
111
|
-
target: ['web', 'es5'],
|
|
112
|
-
cache: {
|
|
113
|
-
type: 'filesystem'
|
|
114
|
-
},
|
|
115
|
-
module: {
|
|
116
|
-
rules: [
|
|
117
|
-
{
|
|
118
|
-
test: /\.vue$/,
|
|
119
|
-
loader: require.resolve('vue-loader'),
|
|
120
|
-
exclude: /node_modules/
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
test: /\.(ts|js)$/,
|
|
124
|
-
exclude: /node_modules/,
|
|
125
|
-
use: [
|
|
126
|
-
{
|
|
127
|
-
loader: require.resolve('swc-loader'),
|
|
128
|
-
options: {
|
|
129
|
-
jsc: {
|
|
130
|
-
parser: {
|
|
131
|
-
syntax: 'typescript',
|
|
132
|
-
tsx: false,
|
|
133
|
-
decorators: true,
|
|
134
|
-
dynamicImport: true
|
|
135
|
-
},
|
|
136
|
-
target: 'es2015'
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
oneOf: [
|
|
144
|
-
{
|
|
145
|
-
test: /\.css$/,
|
|
146
|
-
oneOf: [
|
|
147
|
-
{
|
|
148
|
-
resourceQuery: /module/,
|
|
149
|
-
use: [
|
|
150
|
-
vueStyleLoader,
|
|
151
|
-
{
|
|
152
|
-
loader: cssLoader,
|
|
153
|
-
options: {
|
|
154
|
-
modules: {
|
|
155
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
loader: postcssLoader,
|
|
161
|
-
options: {
|
|
162
|
-
postcssOptions: {
|
|
163
|
-
plugins: [['autoprefixer']]
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
]
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
use: [
|
|
171
|
-
env === 'dev'
|
|
172
|
-
? vueStyleLoader
|
|
173
|
-
: mini_css_extract_plugin_1.default.loader,
|
|
174
|
-
cssLoader,
|
|
175
|
-
{
|
|
176
|
-
loader: postcssLoader,
|
|
177
|
-
options: {
|
|
178
|
-
postcssOptions: {
|
|
179
|
-
plugins: [['autoprefixer']]
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
]
|
|
184
|
-
}
|
|
185
|
-
]
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
test: /\.less$/,
|
|
189
|
-
oneOf: [
|
|
190
|
-
{
|
|
191
|
-
resourceQuery: /module/,
|
|
192
|
-
use: [
|
|
193
|
-
vueStyleLoader,
|
|
194
|
-
{
|
|
195
|
-
loader: cssLoader,
|
|
196
|
-
options: {
|
|
197
|
-
modules: {
|
|
198
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
loader: postcssLoader,
|
|
204
|
-
options: {
|
|
205
|
-
postcssOptions: {
|
|
206
|
-
plugins: [['autoprefixer']]
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
lessLoader
|
|
211
|
-
]
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
use: [
|
|
215
|
-
env === 'dev'
|
|
216
|
-
? vueStyleLoader
|
|
217
|
-
: mini_css_extract_plugin_1.default.loader,
|
|
218
|
-
cssLoader,
|
|
219
|
-
{
|
|
220
|
-
loader: postcssLoader,
|
|
221
|
-
options: {
|
|
222
|
-
postcssOptions: {
|
|
223
|
-
plugins: [['autoprefixer']]
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
lessLoader
|
|
228
|
-
]
|
|
229
|
-
}
|
|
230
|
-
]
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
test: /\.scss$/,
|
|
234
|
-
oneOf: [
|
|
235
|
-
{
|
|
236
|
-
resourceQuery: /module/,
|
|
237
|
-
use: [
|
|
238
|
-
vueStyleLoader,
|
|
239
|
-
{
|
|
240
|
-
loader: cssLoader,
|
|
241
|
-
options: {
|
|
242
|
-
modules: {
|
|
243
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
loader: postcssLoader,
|
|
249
|
-
options: {
|
|
250
|
-
postcssOptions: {
|
|
251
|
-
plugins: [['autoprefixer']]
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
sassLoader
|
|
256
|
-
]
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
use: [
|
|
260
|
-
env === 'dev'
|
|
261
|
-
? vueStyleLoader
|
|
262
|
-
: mini_css_extract_plugin_1.default.loader,
|
|
263
|
-
cssLoader,
|
|
264
|
-
{
|
|
265
|
-
loader: postcssLoader,
|
|
266
|
-
options: {
|
|
267
|
-
postcssOptions: {
|
|
268
|
-
plugins: [['autoprefixer']]
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
sassLoader
|
|
273
|
-
]
|
|
274
|
-
}
|
|
275
|
-
]
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
test: /\.(jpg|png|gif|webp|bmp|jpeg|svg)$/,
|
|
279
|
-
type: 'asset',
|
|
280
|
-
generator: {
|
|
281
|
-
filename: 'images/[name]_[contenthash][ext]'
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
test: /\.(otf|eot|woff2?|ttf)$/i,
|
|
286
|
-
type: 'asset',
|
|
287
|
-
generator: {
|
|
288
|
-
filename: 'fonts/[name]_[contenthash][ext]'
|
|
289
|
-
}
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
test: /\.(txt|xml)$/i,
|
|
293
|
-
type: 'asset/source'
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
test: /\.html$/,
|
|
297
|
-
loader: require.resolve('html-loader')
|
|
298
|
-
}
|
|
299
|
-
]
|
|
300
|
-
}
|
|
301
|
-
]
|
|
302
|
-
},
|
|
303
|
-
resolve: {
|
|
304
|
-
extensions: ['.ts', '.js', '.vue', '.json'],
|
|
305
|
-
alias: __assign({ '@': path_1.default.join(projectPath, '/src'), vue: 'vue/dist/vue.esm-bundler.js', 'vue-router': path_1.default.dirname(require.resolve('vue-router')), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
|
|
306
|
-
},
|
|
307
|
-
externals: customConfig.base.externals,
|
|
308
|
-
plugins: __spreadArray(__spreadArray(__spreadArray([], basicPlugins, true), [
|
|
309
|
-
new vue_loader_1.VueLoaderPlugin(),
|
|
310
|
-
new webpack_1.default.DefinePlugin({
|
|
311
|
-
__VUE_OPTIONS_API__: true,
|
|
312
|
-
__VUE_PROD_DEVTOOLS__: false,
|
|
313
|
-
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
|
|
314
|
-
}),
|
|
315
|
-
new html_webpack_plugin_1.default({
|
|
316
|
-
template: path_1.default.join(projectPath, '/src/index.ejs'),
|
|
317
|
-
filename: 'index.html',
|
|
318
|
-
minify: {
|
|
319
|
-
collapseWhitespace: true,
|
|
320
|
-
removeAttributeQuotes: true
|
|
321
|
-
},
|
|
322
|
-
templateParameters: {
|
|
323
|
-
publicPath: publicPath,
|
|
324
|
-
routerBase: routerBase
|
|
325
|
-
},
|
|
326
|
-
hash: true
|
|
327
|
-
}),
|
|
328
|
-
new mini_css_extract_plugin_1.default({
|
|
329
|
-
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
330
|
-
ignoreOrder: true
|
|
331
|
-
})
|
|
332
|
-
], false), ((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins), true)
|
|
333
|
-
}];
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
exports.default = default_1;
|