swico 1.7.3 → 2.0.0-beta.10
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 +10 -21
- package/src/bin.js +6 -6
- package/src/command/build.js +33 -73
- package/src/command/start.js +100 -192
- package/src/config/rsbpack.dev.js +104 -0
- package/src/config/{webpack.base.react.d.ts → rspack.base.react.d.ts} +43 -6
- package/src/config/rspack.base.react.js +195 -0
- package/src/config/{webpack.base.vue.d.ts → rspack.base.vue.d.ts} +32 -32
- package/src/config/rspack.base.vue.js +167 -0
- package/src/config/rspack.prod.js +122 -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
|
@@ -0,0 +1,104 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const config_1 = require("../utils/config");
|
|
39
|
+
const path_1 = __importDefault(require("path"));
|
|
40
|
+
const webpack_merge_1 = require("webpack-merge");
|
|
41
|
+
const eslint_webpack_plugin_1 = __importDefault(require("eslint-webpack-plugin"));
|
|
42
|
+
const ts_checker_rspack_plugin_1 = require("ts-checker-rspack-plugin");
|
|
43
|
+
const tools_1 = require("../utils/tools");
|
|
44
|
+
function default_1(options) {
|
|
45
|
+
var _a, _b, _c, _d, _e;
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const { projectPath, customConfig, templateType, entryPath, env } = options;
|
|
48
|
+
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './rspack.base.vue' : './rspack.base.react'}`).then(s => __importStar(require(s)))).default;
|
|
49
|
+
const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'dev' }));
|
|
50
|
+
const customDevtool = (_a = customConfig.dev.devtool) !== null && _a !== void 0 ? _a : customConfig.base.devtool;
|
|
51
|
+
return (0, webpack_merge_1.merge)(baseConfig, {
|
|
52
|
+
mode: 'development',
|
|
53
|
+
stats: 'none',
|
|
54
|
+
devtool: templateType === 'vue'
|
|
55
|
+
? customDevtool !== null && customDevtool !== void 0 ? customDevtool : 'cheap-module-source-map'
|
|
56
|
+
: customDevtool !== null && customDevtool !== void 0 ? customDevtool : 'eval-cheap-module-source-map',
|
|
57
|
+
devServer: {
|
|
58
|
+
historyApiFallback: {
|
|
59
|
+
index: `${baseConfig.output.publicPath}index.html`
|
|
60
|
+
},
|
|
61
|
+
client: {
|
|
62
|
+
logging: 'error',
|
|
63
|
+
progress: false,
|
|
64
|
+
overlay: false
|
|
65
|
+
},
|
|
66
|
+
proxy: (_c = (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.dev) === null || _b === void 0 ? void 0 : _b.proxy) !== null && _c !== void 0 ? _c : config_1.initConfig.proxy,
|
|
67
|
+
compress: true,
|
|
68
|
+
hot: false,
|
|
69
|
+
open: false,
|
|
70
|
+
liveReload: true,
|
|
71
|
+
static: {
|
|
72
|
+
directory: path_1.default.join(projectPath, '/public')
|
|
73
|
+
},
|
|
74
|
+
server: customConfig.dev.https === true ? 'https' : 'http'
|
|
75
|
+
},
|
|
76
|
+
plugins: [
|
|
77
|
+
new ts_checker_rspack_plugin_1.TsCheckerRspackPlugin({
|
|
78
|
+
logger: {
|
|
79
|
+
log: () => { },
|
|
80
|
+
error: (message) => {
|
|
81
|
+
tools_1.toast.error(message, { title: 'TypeScript errors' });
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
typescript: {
|
|
85
|
+
diagnosticOptions: {
|
|
86
|
+
semantic: true,
|
|
87
|
+
syntactic: true
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}),
|
|
91
|
+
new eslint_webpack_plugin_1.default({
|
|
92
|
+
context: path_1.default.join(projectPath, '/src'),
|
|
93
|
+
failOnError: false,
|
|
94
|
+
failOnWarning: true,
|
|
95
|
+
extensions: templateType === 'vue' ? ['vue', 'ts', 'js'] : ['tsx', 'ts', 'js'],
|
|
96
|
+
emitWarning: false,
|
|
97
|
+
cache: true
|
|
98
|
+
}),
|
|
99
|
+
...((_e = (_d = customConfig.dev) === null || _d === void 0 ? void 0 : _d.plugins) !== null && _e !== void 0 ? _e : [])
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
exports.default = default_1;
|
|
@@ -4,15 +4,23 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
4
4
|
output: {
|
|
5
5
|
path: string;
|
|
6
6
|
filename: string;
|
|
7
|
+
chunkFilename: string;
|
|
8
|
+
cssFilename: string;
|
|
9
|
+
cssChunkFilename: string;
|
|
7
10
|
assetModuleFilename: string;
|
|
8
11
|
publicPath: string;
|
|
9
12
|
clean: boolean;
|
|
10
13
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type: string;
|
|
14
|
+
experiments: {
|
|
15
|
+
css: boolean;
|
|
14
16
|
};
|
|
17
|
+
target: string[];
|
|
15
18
|
module: {
|
|
19
|
+
parser: {
|
|
20
|
+
'css/auto': {
|
|
21
|
+
namedExports: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
16
24
|
rules: ({
|
|
17
25
|
test: RegExp;
|
|
18
26
|
exclude: RegExp;
|
|
@@ -41,8 +49,37 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
41
49
|
} | {
|
|
42
50
|
oneOf: ({
|
|
43
51
|
test: RegExp;
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
type: string;
|
|
53
|
+
use: (string | {
|
|
54
|
+
loader: string;
|
|
55
|
+
options: {
|
|
56
|
+
postcssOptions: {
|
|
57
|
+
plugins: string[][];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
})[];
|
|
61
|
+
generator?: undefined;
|
|
62
|
+
loader?: undefined;
|
|
63
|
+
} | {
|
|
64
|
+
test: RegExp;
|
|
65
|
+
type: string;
|
|
66
|
+
use: ({
|
|
67
|
+
loader: string;
|
|
68
|
+
options: {
|
|
69
|
+
postcssOptions: {
|
|
70
|
+
plugins: string[][];
|
|
71
|
+
};
|
|
72
|
+
api?: undefined;
|
|
73
|
+
implementation?: undefined;
|
|
74
|
+
};
|
|
75
|
+
} | {
|
|
76
|
+
loader: string;
|
|
77
|
+
options: {
|
|
78
|
+
api: string;
|
|
79
|
+
implementation: string;
|
|
80
|
+
postcssOptions?: undefined;
|
|
81
|
+
};
|
|
82
|
+
})[];
|
|
46
83
|
generator?: undefined;
|
|
47
84
|
loader?: undefined;
|
|
48
85
|
} | {
|
|
@@ -62,8 +99,8 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
62
99
|
} | {
|
|
63
100
|
test: RegExp;
|
|
64
101
|
loader: string;
|
|
65
|
-
use?: undefined;
|
|
66
102
|
type?: undefined;
|
|
103
|
+
use?: undefined;
|
|
67
104
|
generator?: undefined;
|
|
68
105
|
})[];
|
|
69
106
|
test?: undefined;
|
|
@@ -0,0 +1,195 @@
|
|
|
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
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const config_1 = require("../utils/config");
|
|
17
|
+
const core_1 = require("@rspack/core");
|
|
18
|
+
const cssLoader = require.resolve('css-loader');
|
|
19
|
+
const lessLoader = require.resolve('less-loader');
|
|
20
|
+
const sassLoader = require.resolve('sass-loader');
|
|
21
|
+
const postcssLoader = require.resolve('postcss-loader');
|
|
22
|
+
function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
23
|
+
var _a, _b, _c;
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const customBaseConfig = customConfig.base;
|
|
26
|
+
const getCustomAliasConfig = () => {
|
|
27
|
+
const { alias } = customBaseConfig || {};
|
|
28
|
+
const custAliasConfig = {};
|
|
29
|
+
if (alias) {
|
|
30
|
+
Object.keys(alias).forEach((key) => {
|
|
31
|
+
custAliasConfig[key] = path_1.default.join(projectPath, `/${alias[key]}`);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return custAliasConfig;
|
|
35
|
+
};
|
|
36
|
+
const publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
|
|
37
|
+
const routerBase = ((_a = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _a === void 0 ? void 0 : _a.base) || config_1.initConfig.router.base;
|
|
38
|
+
const basicPlugins = [];
|
|
39
|
+
const defineConfigData = (_c = (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _b === void 0 ? void 0 : _b.define) !== null && _c !== void 0 ? _c : {};
|
|
40
|
+
const formatObj = yield (0, config_1.getFormatDefineVars)(defineConfigData);
|
|
41
|
+
if (Object.keys(formatObj).length !== 0) {
|
|
42
|
+
basicPlugins.push(new core_1.rspack.DefinePlugin(formatObj));
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
entry: entryPath,
|
|
46
|
+
output: {
|
|
47
|
+
path: path_1.default.join(projectPath, '/dist'),
|
|
48
|
+
filename: 'js/[name].[chunkhash].js',
|
|
49
|
+
chunkFilename: 'js/[name].[chunkhash].js',
|
|
50
|
+
cssFilename: 'css/[name].[contenthash].css',
|
|
51
|
+
cssChunkFilename: 'css/[name].[contenthash].css',
|
|
52
|
+
assetModuleFilename: 'assets/[name]_[chunkhash][ext]',
|
|
53
|
+
publicPath,
|
|
54
|
+
clean: true
|
|
55
|
+
},
|
|
56
|
+
experiments: {
|
|
57
|
+
css: true
|
|
58
|
+
},
|
|
59
|
+
target: ['web', 'es2015'],
|
|
60
|
+
module: {
|
|
61
|
+
parser: {
|
|
62
|
+
'css/auto': {
|
|
63
|
+
namedExports: false
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
rules: [
|
|
67
|
+
{
|
|
68
|
+
test: /\.(tsx|ts|jsx)$/,
|
|
69
|
+
exclude: /node_modules/,
|
|
70
|
+
use: [
|
|
71
|
+
{
|
|
72
|
+
loader: 'builtin:swc-loader',
|
|
73
|
+
options: {
|
|
74
|
+
jsc: {
|
|
75
|
+
parser: {
|
|
76
|
+
syntax: 'typescript',
|
|
77
|
+
tsx: true,
|
|
78
|
+
decorators: true,
|
|
79
|
+
dynamicImport: true
|
|
80
|
+
},
|
|
81
|
+
transform: {
|
|
82
|
+
react: {
|
|
83
|
+
runtime: 'automatic',
|
|
84
|
+
useBuiltins: true,
|
|
85
|
+
importSource: 'react'
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
target: 'es2015'
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
oneOf: [
|
|
96
|
+
{
|
|
97
|
+
test: /\.css$/,
|
|
98
|
+
type: 'css/auto',
|
|
99
|
+
use: [
|
|
100
|
+
cssLoader,
|
|
101
|
+
{
|
|
102
|
+
loader: postcssLoader,
|
|
103
|
+
options: {
|
|
104
|
+
postcssOptions: {
|
|
105
|
+
plugins: [['autoprefixer']]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
test: /\.less$/,
|
|
113
|
+
type: 'css/auto',
|
|
114
|
+
use: [
|
|
115
|
+
{
|
|
116
|
+
loader: postcssLoader,
|
|
117
|
+
options: {
|
|
118
|
+
postcssOptions: {
|
|
119
|
+
plugins: [['autoprefixer']]
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
lessLoader
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
test: /\.scss$/,
|
|
128
|
+
type: 'css/auto',
|
|
129
|
+
use: [
|
|
130
|
+
{
|
|
131
|
+
loader: postcssLoader,
|
|
132
|
+
options: {
|
|
133
|
+
postcssOptions: {
|
|
134
|
+
plugins: [['autoprefixer']]
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
loader: sassLoader,
|
|
140
|
+
options: {
|
|
141
|
+
api: 'modern-compiler',
|
|
142
|
+
implementation: require.resolve('sass-embedded')
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
test: /\.(jpg|png|gif|webp|bmp|jpeg|svg)$/,
|
|
149
|
+
type: 'asset',
|
|
150
|
+
generator: {
|
|
151
|
+
filename: 'images/[name]_[contenthash][ext]'
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
test: /\.(otf|eot|woff2?|ttf)$/i,
|
|
156
|
+
type: 'asset',
|
|
157
|
+
generator: {
|
|
158
|
+
filename: 'fonts/[name]_[contenthash][ext]'
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
test: /\.(txt|xml)$/i,
|
|
163
|
+
type: 'asset/source'
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
test: /\.html$/,
|
|
167
|
+
loader: require.resolve('html-loader')
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
resolve: {
|
|
174
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
175
|
+
alias: Object.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())
|
|
176
|
+
},
|
|
177
|
+
externals: customConfig.base.externals,
|
|
178
|
+
plugins: [
|
|
179
|
+
...basicPlugins,
|
|
180
|
+
new core_1.rspack.HtmlRspackPlugin({
|
|
181
|
+
template: path_1.default.join(projectPath, '/src/index.ejs'),
|
|
182
|
+
filename: 'index.html',
|
|
183
|
+
minify: true,
|
|
184
|
+
templateParameters: {
|
|
185
|
+
publicPath,
|
|
186
|
+
routerBase
|
|
187
|
+
},
|
|
188
|
+
hash: true
|
|
189
|
+
}),
|
|
190
|
+
...((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins)
|
|
191
|
+
]
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
exports.default = default_1;
|
|
@@ -4,19 +4,30 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
4
4
|
output: {
|
|
5
5
|
path: string;
|
|
6
6
|
filename: string;
|
|
7
|
+
chunkFilename: string;
|
|
8
|
+
cssFilename: string;
|
|
9
|
+
cssChunkFilename: string;
|
|
7
10
|
assetModuleFilename: string;
|
|
8
11
|
publicPath: string;
|
|
9
12
|
clean: boolean;
|
|
10
13
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type: string;
|
|
14
|
+
experiments: {
|
|
15
|
+
css: boolean;
|
|
14
16
|
};
|
|
17
|
+
target: string[];
|
|
15
18
|
module: {
|
|
19
|
+
parser: {
|
|
20
|
+
'css/auto': {
|
|
21
|
+
namedExports: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
16
24
|
rules: ({
|
|
17
25
|
test: RegExp;
|
|
18
26
|
loader: string;
|
|
19
27
|
exclude: RegExp;
|
|
28
|
+
options: {
|
|
29
|
+
experimentalInlineMatchResource: boolean;
|
|
30
|
+
};
|
|
20
31
|
use?: undefined;
|
|
21
32
|
oneOf?: undefined;
|
|
22
33
|
} | {
|
|
@@ -37,60 +48,49 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
37
48
|
};
|
|
38
49
|
}[];
|
|
39
50
|
loader?: undefined;
|
|
51
|
+
options?: undefined;
|
|
40
52
|
oneOf?: undefined;
|
|
41
53
|
} | {
|
|
42
54
|
oneOf: ({
|
|
43
55
|
test: RegExp;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
options: {
|
|
57
|
-
postcssOptions: {
|
|
58
|
-
plugins: string[][];
|
|
59
|
-
};
|
|
60
|
-
modules?: undefined;
|
|
61
|
-
};
|
|
62
|
-
})[];
|
|
63
|
-
} | {
|
|
64
|
-
use: any[];
|
|
65
|
-
resourceQuery?: undefined;
|
|
66
|
-
})[];
|
|
67
|
-
type?: undefined;
|
|
56
|
+
type: string;
|
|
57
|
+
loader: string;
|
|
58
|
+
options?: undefined;
|
|
59
|
+
generator?: undefined;
|
|
60
|
+
} | {
|
|
61
|
+
test: RegExp;
|
|
62
|
+
type: string;
|
|
63
|
+
loader: string;
|
|
64
|
+
options: {
|
|
65
|
+
api: string;
|
|
66
|
+
implementation: string;
|
|
67
|
+
};
|
|
68
68
|
generator?: undefined;
|
|
69
|
-
loader?: undefined;
|
|
70
69
|
} | {
|
|
71
70
|
test: RegExp;
|
|
72
71
|
type: string;
|
|
73
72
|
generator: {
|
|
74
73
|
filename: string;
|
|
75
74
|
};
|
|
76
|
-
oneOf?: undefined;
|
|
77
75
|
loader?: undefined;
|
|
76
|
+
options?: undefined;
|
|
78
77
|
} | {
|
|
79
78
|
test: RegExp;
|
|
80
79
|
type: string;
|
|
81
|
-
oneOf?: undefined;
|
|
82
|
-
generator?: undefined;
|
|
83
80
|
loader?: undefined;
|
|
81
|
+
options?: undefined;
|
|
82
|
+
generator?: undefined;
|
|
84
83
|
} | {
|
|
85
84
|
test: RegExp;
|
|
86
85
|
loader: string;
|
|
87
|
-
oneOf?: undefined;
|
|
88
86
|
type?: undefined;
|
|
87
|
+
options?: undefined;
|
|
89
88
|
generator?: undefined;
|
|
90
89
|
})[];
|
|
91
90
|
test?: undefined;
|
|
92
91
|
loader?: undefined;
|
|
93
92
|
exclude?: undefined;
|
|
93
|
+
options?: undefined;
|
|
94
94
|
use?: undefined;
|
|
95
95
|
})[];
|
|
96
96
|
};
|
|
@@ -0,0 +1,167 @@
|
|
|
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
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const config_1 = require("../utils/config");
|
|
17
|
+
const vue_loader_1 = require("vue-loader");
|
|
18
|
+
const core_1 = require("@rspack/core");
|
|
19
|
+
const vueStyleLoader = require.resolve('vue-style-loader');
|
|
20
|
+
const cssLoader = require.resolve('css-loader');
|
|
21
|
+
const lessLoader = require.resolve('less-loader');
|
|
22
|
+
const sassLoader = require.resolve('sass-loader');
|
|
23
|
+
const postcssLoader = require.resolve('postcss-loader');
|
|
24
|
+
function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const customBaseConfig = customConfig.base;
|
|
28
|
+
const getCustomAliasConfig = () => {
|
|
29
|
+
const { alias } = customBaseConfig || {};
|
|
30
|
+
const custAliasConfig = {};
|
|
31
|
+
if (alias) {
|
|
32
|
+
Object.keys(alias).forEach((key) => {
|
|
33
|
+
custAliasConfig[key] = path_1.default.join(projectPath, `/${alias[key]}`);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return custAliasConfig;
|
|
37
|
+
};
|
|
38
|
+
const publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
|
|
39
|
+
const routerBase = ((_a = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _a === void 0 ? void 0 : _a.base) || config_1.initConfig.router.base;
|
|
40
|
+
const basicPlugins = [];
|
|
41
|
+
const defineConfigData = (_c = (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _b === void 0 ? void 0 : _b.define) !== null && _c !== void 0 ? _c : {};
|
|
42
|
+
const formatObj = yield (0, config_1.getFormatDefineVars)(defineConfigData);
|
|
43
|
+
if (Object.keys(formatObj).length !== 0) {
|
|
44
|
+
basicPlugins.push(new core_1.rspack.DefinePlugin(formatObj));
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
entry: entryPath,
|
|
48
|
+
output: {
|
|
49
|
+
path: path_1.default.join(projectPath, '/dist'),
|
|
50
|
+
filename: 'js/[name].[chunkhash].js',
|
|
51
|
+
chunkFilename: 'js/[name].[chunkhash].js',
|
|
52
|
+
cssFilename: 'css/[name].[contenthash].css',
|
|
53
|
+
cssChunkFilename: 'css/[name].[contenthash].css',
|
|
54
|
+
assetModuleFilename: 'assets/[name]_[id][ext]',
|
|
55
|
+
publicPath,
|
|
56
|
+
clean: true
|
|
57
|
+
},
|
|
58
|
+
experiments: {
|
|
59
|
+
css: true
|
|
60
|
+
},
|
|
61
|
+
target: ['web', 'es5'],
|
|
62
|
+
module: {
|
|
63
|
+
parser: {
|
|
64
|
+
'css/auto': {
|
|
65
|
+
namedExports: false
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
rules: [
|
|
69
|
+
{
|
|
70
|
+
test: /\.vue$/,
|
|
71
|
+
loader: require.resolve('vue-loader'),
|
|
72
|
+
exclude: /node_modules/,
|
|
73
|
+
options: {
|
|
74
|
+
experimentalInlineMatchResource: true
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
test: /\.(ts|js)$/,
|
|
79
|
+
exclude: /node_modules/,
|
|
80
|
+
use: [
|
|
81
|
+
{
|
|
82
|
+
loader: 'builtin:swc-loader',
|
|
83
|
+
options: {
|
|
84
|
+
jsc: {
|
|
85
|
+
parser: {
|
|
86
|
+
syntax: 'typescript',
|
|
87
|
+
tsx: false,
|
|
88
|
+
decorators: true,
|
|
89
|
+
dynamicImport: true
|
|
90
|
+
},
|
|
91
|
+
target: 'es2015'
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
oneOf: [
|
|
99
|
+
{
|
|
100
|
+
test: /\.less$/,
|
|
101
|
+
type: 'css',
|
|
102
|
+
loader: lessLoader
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
test: /\.scss$/,
|
|
106
|
+
type: 'css',
|
|
107
|
+
loader: sassLoader,
|
|
108
|
+
options: {
|
|
109
|
+
api: 'modern-compiler',
|
|
110
|
+
implementation: require.resolve('sass-embedded')
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
test: /\.(jpg|png|gif|webp|bmp|jpeg|svg)$/,
|
|
115
|
+
type: 'asset',
|
|
116
|
+
generator: {
|
|
117
|
+
filename: 'images/[name]_[contenthash][ext]'
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
test: /\.(otf|eot|woff2?|ttf)$/i,
|
|
122
|
+
type: 'asset',
|
|
123
|
+
generator: {
|
|
124
|
+
filename: 'fonts/[name]_[contenthash][ext]'
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
test: /\.(txt|xml)$/i,
|
|
129
|
+
type: 'asset/source'
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
test: /\.html$/,
|
|
133
|
+
loader: require.resolve('html-loader')
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
resolve: {
|
|
140
|
+
extensions: ['.ts', '.js', '.vue', '.json'],
|
|
141
|
+
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')), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
|
|
142
|
+
},
|
|
143
|
+
externals: customConfig.base.externals,
|
|
144
|
+
plugins: [
|
|
145
|
+
...basicPlugins,
|
|
146
|
+
new vue_loader_1.VueLoaderPlugin(),
|
|
147
|
+
new core_1.rspack.DefinePlugin({
|
|
148
|
+
__VUE_OPTIONS_API__: true,
|
|
149
|
+
__VUE_PROD_DEVTOOLS__: false,
|
|
150
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
|
|
151
|
+
}),
|
|
152
|
+
new core_1.rspack.HtmlRspackPlugin({
|
|
153
|
+
template: path_1.default.join(projectPath, '/src/index.ejs'),
|
|
154
|
+
filename: 'index.html',
|
|
155
|
+
minify: true,
|
|
156
|
+
templateParameters: {
|
|
157
|
+
publicPath,
|
|
158
|
+
routerBase
|
|
159
|
+
},
|
|
160
|
+
hash: true
|
|
161
|
+
}),
|
|
162
|
+
...((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins)
|
|
163
|
+
]
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
exports.default = default_1;
|