@itera-web/cli 1.1.54

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.
Files changed (61) hide show
  1. package/README.md +56 -0
  2. package/bin/index.js +18 -0
  3. package/dist/commands/app/app-obs.d.ts +14 -0
  4. package/dist/commands/app/app-obs.js +243 -0
  5. package/dist/commands/app/up.d.ts +11 -0
  6. package/dist/commands/app/up.js +103 -0
  7. package/dist/commands/web/buildapp.d.ts +10 -0
  8. package/dist/commands/web/buildapp.js +106 -0
  9. package/dist/commands/web/git.d.ts +3 -0
  10. package/dist/commands/web/git.js +57 -0
  11. package/dist/commands/web/init.d.ts +4 -0
  12. package/dist/commands/web/init.js +129 -0
  13. package/dist/commands/web/packageapp.d.ts +5 -0
  14. package/dist/commands/web/packageapp.js +98 -0
  15. package/dist/commands/web/publish.d.ts +10 -0
  16. package/dist/commands/web/publish.js +104 -0
  17. package/dist/commands/web/pullprojects.d.ts +5 -0
  18. package/dist/commands/web/pullprojects.js +108 -0
  19. package/dist/commands/web/startapp.d.ts +5 -0
  20. package/dist/commands/web/startapp.js +98 -0
  21. package/dist/commands/web/updateprojects.d.ts +17 -0
  22. package/dist/commands/web/updateprojects.js +220 -0
  23. package/dist/config/util.d.ts +14 -0
  24. package/dist/config/util.js +88 -0
  25. package/dist/config/webpack.buildpackage.d.ts +1 -0
  26. package/dist/config/webpack.buildpackage.js +63 -0
  27. package/dist/config/webpack.common.d.ts +1 -0
  28. package/dist/config/webpack.common.js +178 -0
  29. package/dist/config/webpack.dev.d.ts +1 -0
  30. package/dist/config/webpack.dev.js +27 -0
  31. package/dist/config/webpack.pro.d.ts +1 -0
  32. package/dist/config/webpack.pro.js +43 -0
  33. package/dist/plugins/app.exe +0 -0
  34. package/dist/plugins/sortSrciptTag.d.ts +1 -0
  35. package/dist/plugins/sortSrciptTag.js +75 -0
  36. package/dist/plugins/webSocketServer.d.ts +4 -0
  37. package/dist/plugins/webSocketServer.js +53 -0
  38. package/dist/public/git.d.ts +1 -0
  39. package/dist/public/git.js +375 -0
  40. package/dist/public/hook.d.ts +18 -0
  41. package/dist/public/hook.js +93 -0
  42. package/dist/public/log.d.ts +8 -0
  43. package/dist/public/log.js +58 -0
  44. package/dist/public/public.d.ts +19 -0
  45. package/dist/public/public.js +425 -0
  46. package/dist/public/sign.d.ts +2 -0
  47. package/dist/public/sign.js +148 -0
  48. package/dist/public/smartMerge.d.ts +3 -0
  49. package/dist/public/smartMerge.js +31 -0
  50. package/dist/public/update-version.d.ts +2 -0
  51. package/dist/public/update-version.js +130 -0
  52. package/dist/public/upload-obs.d.ts +1 -0
  53. package/dist/public/upload-obs.js +242 -0
  54. package/dist/public/upload-web.d.ts +1 -0
  55. package/dist/public/upload-web.js +154 -0
  56. package/dist/store/index.d.ts +2 -0
  57. package/dist/store/index.js +65 -0
  58. package/dist/store/types.d.ts +53 -0
  59. package/dist/store/types.js +2 -0
  60. package/package.json +110 -0
  61. package/tsconfig.json +30 -0
@@ -0,0 +1,220 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
14
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
+ 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;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
39
+ var __importDefault = (this && this.__importDefault) || function (mod) {
40
+ return (mod && mod.__esModule) ? mod : { "default": mod };
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
44
+ var child_process_1 = require("child_process");
45
+ var fs_1 = __importDefault(require("fs"));
46
+ var p_limit_1 = __importDefault(require("p-limit"));
47
+ var path_1 = __importDefault(require("path"));
48
+ var webSocketServer_1 = require("../../plugins/webSocketServer");
49
+ var log_1 = require("../../public/log");
50
+ var public_1 = require("../../public/public");
51
+ var runtimePath = process.cwd();
52
+ var runCommand = function (cmd, cwd) {
53
+ return new Promise(function (resolve, reject) {
54
+ var shell = process.platform === 'win32' ? 'cmd.exe' : '/bin/sh';
55
+ var args = process.platform === 'win32' ? ['/c', cmd] : ['-c', cmd];
56
+ var child = (0, child_process_1.spawn)(shell, args, { cwd: cwd, stdio: 'inherit' });
57
+ child.on('close', function (code) {
58
+ if (code === 0)
59
+ resolve();
60
+ else
61
+ reject(new Error("\u547D\u4EE4\u6267\u884C\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ".concat(code)));
62
+ });
63
+ child.on('error', function (err) { return reject(err); });
64
+ });
65
+ };
66
+ exports.command = 'update-projects';
67
+ exports.describe = '批量更新项目依赖';
68
+ exports.builder = {
69
+ parallel: {
70
+ type: 'boolean',
71
+ default: false,
72
+ describe: '是否开启并行执行',
73
+ },
74
+ concurrency: {
75
+ type: 'number',
76
+ default: 3,
77
+ describe: '并行执行的最大项目数量,仅在 --parallel 时生效',
78
+ },
79
+ };
80
+ var handler = function (argv) { return __awaiter(void 0, void 0, void 0, function () {
81
+ var isRunning, configPath, defaultConfig, appPath, child;
82
+ return __generator(this, function (_a) {
83
+ switch (_a.label) {
84
+ case 0: return [4, (0, public_1.onCheckIteraCliVersion)()];
85
+ case 1:
86
+ _a.sent();
87
+ (0, webSocketServer_1.WebsocketServerInit)();
88
+ isRunning = false;
89
+ configPath = path_1.default.resolve(runtimePath, 'update_projects_config.js');
90
+ if (!fs_1.default.existsSync(configPath)) {
91
+ log_1.Console.warn('⚠️ 配置文件 [update_projects_config.js] 已初始化,请在 [update_projects_config.js] 内添加项目和需要执行的命令');
92
+ defaultConfig = [
93
+ {
94
+ name: 'D:/Project/项目1根目录',
95
+ commands: [
96
+ 'npm run check',
97
+ 'npm install',
98
+ 'npm run publish',
99
+ 'git add .',
100
+ 'git commit -m "提交描述"',
101
+ 'git push',
102
+ ],
103
+ },
104
+ ];
105
+ fs_1.default.writeFileSync(configPath, "module.exports = ".concat(JSON.stringify(defaultConfig, null, 2), ";\n"), 'utf-8');
106
+ process.exit(0);
107
+ }
108
+ appPath = path_1.default.resolve(__dirname, '..', '..', 'plugins', 'app.exe');
109
+ child = (0, child_process_1.spawn)(appPath, [configPath]);
110
+ child.stdout.on('data', function (data) { return __awaiter(void 0, void 0, void 0, function () {
111
+ var config, runProject_1, limit_1, tasks, _a, _i, config_1, project, _b, e_1;
112
+ return __generator(this, function (_c) {
113
+ switch (_c.label) {
114
+ case 0:
115
+ if (isRunning) {
116
+ log_1.Console.warn('任务正在执行,请耐心等待');
117
+ return [2];
118
+ }
119
+ _c.label = 1;
120
+ case 1:
121
+ _c.trys.push([1, 14, , 15]);
122
+ config = JSON.parse(data.toString());
123
+ isRunning = true;
124
+ runProject_1 = function (project) { return __awaiter(void 0, void 0, void 0, function () {
125
+ var projectPath, _i, _a, cmd, err_1;
126
+ return __generator(this, function (_b) {
127
+ switch (_b.label) {
128
+ case 0:
129
+ projectPath = path_1.default.resolve(runtimePath, project.name);
130
+ log_1.Console.cyan("\n\uD83D\uDE80 \u5F00\u59CB\u6267\u884C\u9879\u76EE\u547D\u4EE4: ".concat(project.name));
131
+ _i = 0, _a = project.commands;
132
+ _b.label = 1;
133
+ case 1:
134
+ if (!(_i < _a.length)) return [3, 6];
135
+ cmd = _a[_i];
136
+ log_1.Console.info("\uD83D\uDC49 [".concat(project.name, "] \u6B63\u5728\u6267\u884C\u547D\u4EE4: [").concat(cmd, "] "));
137
+ _b.label = 2;
138
+ case 2:
139
+ _b.trys.push([2, 4, , 5]);
140
+ return [4, runCommand(cmd, projectPath)];
141
+ case 3:
142
+ _b.sent();
143
+ (0, webSocketServer_1.sendWSMessage)({ cmd: cmd, name: project.name });
144
+ return [3, 5];
145
+ case 4:
146
+ err_1 = _b.sent();
147
+ log_1.Console.error("\u274C [".concat(project.name, "] \u6267\u884C\u547D\u4EE4\u5931\u8D25: [").concat(cmd, "] ").concat(err_1));
148
+ throw err_1;
149
+ case 5:
150
+ _i++;
151
+ return [3, 1];
152
+ case 6: return [2];
153
+ }
154
+ });
155
+ }); };
156
+ if (!argv.parallel) return [3, 6];
157
+ limit_1 = (0, p_limit_1.default)(argv.concurrency);
158
+ tasks = config.map(function (project) { return limit_1(function () { return runProject_1(project); }); });
159
+ _c.label = 2;
160
+ case 2:
161
+ _c.trys.push([2, 4, , 5]);
162
+ return [4, Promise.all(tasks)];
163
+ case 3:
164
+ _c.sent();
165
+ log_1.Console.success('\n🎉 所有项目并行执行完成');
166
+ isRunning = false;
167
+ process.exit(0);
168
+ return [3, 5];
169
+ case 4:
170
+ _a = _c.sent();
171
+ log_1.Console.error('\n❌ 部分项目执行失败');
172
+ process.exit(1);
173
+ return [3, 5];
174
+ case 5: return [3, 13];
175
+ case 6:
176
+ _i = 0, config_1 = config;
177
+ _c.label = 7;
178
+ case 7:
179
+ if (!(_i < config_1.length)) return [3, 12];
180
+ project = config_1[_i];
181
+ _c.label = 8;
182
+ case 8:
183
+ _c.trys.push([8, 10, , 11]);
184
+ return [4, runProject_1(project)];
185
+ case 9:
186
+ _c.sent();
187
+ return [3, 11];
188
+ case 10:
189
+ _b = _c.sent();
190
+ process.exit(1);
191
+ return [3, 11];
192
+ case 11:
193
+ _i++;
194
+ return [3, 7];
195
+ case 12:
196
+ log_1.Console.success('\n✅ 所有项目串行执行完成');
197
+ isRunning = false;
198
+ process.exit(0);
199
+ _c.label = 13;
200
+ case 13: return [3, 15];
201
+ case 14:
202
+ e_1 = _c.sent();
203
+ isRunning = false;
204
+ return [3, 15];
205
+ case 15: return [2];
206
+ }
207
+ });
208
+ }); });
209
+ child.on('close', function (code) {
210
+ log_1.Console.info("Itera-Cli\u89C6\u7A97 \u5B50\u8FDB\u7A0B\u9000\u51FA\uFF0C\u9000\u51FA\u7801 ".concat(code));
211
+ });
212
+ child.on('error', function (err) {
213
+ log_1.Console.error('Itera-Cli视窗 子进程启动失败', err);
214
+ process.exit(1);
215
+ });
216
+ return [2];
217
+ }
218
+ });
219
+ }); };
220
+ exports.handler = handler;
@@ -0,0 +1,14 @@
1
+ export default Util;
2
+ declare namespace Util {
3
+ function slash(input: any): any[];
4
+ function getEnv(commandPath: any): NodeJS.ProcessEnv & {
5
+ Path: any;
6
+ PATH: any;
7
+ };
8
+ function getPostCssConfigPath(runtimePath: any): string;
9
+ function getBabelConfigPath(runtimePath: any): string;
10
+ function getEntryIndex(runtimePath: any): string;
11
+ function isWin32(): boolean;
12
+ function isDev(): boolean;
13
+ function isProd(): boolean;
14
+ }
@@ -0,0 +1,88 @@
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
+ var fs_1 = __importDefault(require("fs"));
7
+ var path_1 = __importDefault(require("path"));
8
+ function getEvnSplit() {
9
+ return Util.isWin32() ? ';' : ':';
10
+ }
11
+ function sortPathByDesc(path) {
12
+ var regExp = '';
13
+ if (Util.isWin32()) {
14
+ regExp = /;{1,}/;
15
+ }
16
+ else {
17
+ regExp = /:{1,}/;
18
+ }
19
+ var pathArr = path.split(regExp);
20
+ pathArr.sort(function (p1, p2) {
21
+ if (p1.length > p2.length)
22
+ return -1;
23
+ else if (p1.length < p2.length)
24
+ return 1;
25
+ else
26
+ return 0;
27
+ });
28
+ return pathArr.join(getEvnSplit());
29
+ }
30
+ var Util = {
31
+ slash: function (input) {
32
+ var isExtendedLengthPath = /^\\\\\?\\/.test(input);
33
+ if (isExtendedLengthPath) {
34
+ return input;
35
+ }
36
+ return input.replace(/\\/g, '/');
37
+ },
38
+ getEnv: function (commandPath) {
39
+ var obj = {};
40
+ if (process.env && process.env.Path && process.env.Path.indexOf(commandPath) === -1) {
41
+ obj.Path = process.env.Path + getEvnSplit() + commandPath;
42
+ obj.Path = sortPathByDesc(obj.Path);
43
+ }
44
+ if (process.env && process.env.PATH && process.env.PATH.indexOf(commandPath) === -1) {
45
+ obj.PATH = process.env.PATH + getEvnSplit() + commandPath;
46
+ obj.PATH = sortPathByDesc(obj.PATH);
47
+ }
48
+ return Object.assign(process.env, obj);
49
+ },
50
+ getPostCssConfigPath: function (runtimePath) {
51
+ if (fs_1.default.existsSync(path_1.default.join(runtimePath, 'postcss.config.js'))) {
52
+ return path_1.default.join(runtimePath, 'postcss.config.js');
53
+ }
54
+ return path_1.default.join(__dirname, '../', 'postcss.config.js');
55
+ },
56
+ getBabelConfigPath: function (runtimePath) {
57
+ if (fs_1.default.existsSync(path_1.default.join(runtimePath, 'babel.config.js'))) {
58
+ return path_1.default.join(runtimePath, 'babel.config.js');
59
+ }
60
+ return path_1.default.join(__dirname, '../', 'babel.config.js');
61
+ },
62
+ getEntryIndex: function (runtimePath) {
63
+ var extensionNames = ['.js', '.jsx', '.ts', '.tsx'];
64
+ var index = -1;
65
+ for (var i = 0; i < extensionNames.length; i++) {
66
+ var extensionName = extensionNames[i];
67
+ var exists = fs_1.default.existsSync(path_1.default.join(runtimePath, 'src', "index".concat(extensionName)));
68
+ if (exists) {
69
+ index = i;
70
+ break;
71
+ }
72
+ }
73
+ var entryIndexName = index !== -1 ? "index".concat(extensionNames[index]) : 'index.js';
74
+ return path_1.default.join(runtimePath, 'src', entryIndexName);
75
+ },
76
+ isWin32: function () {
77
+ return process.platform === 'win32';
78
+ },
79
+ isDev: function () {
80
+ var mode = process.env.mode;
81
+ return mode === 'development';
82
+ },
83
+ isProd: function () {
84
+ var mode = process.env.mode;
85
+ return mode === 'production';
86
+ },
87
+ };
88
+ exports.default = Util;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,63 @@
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
+ var css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-webpack-plugin"));
7
+ var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
8
+ var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
9
+ var path_1 = __importDefault(require("path"));
10
+ var terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
11
+ var webpack_1 = __importDefault(require("webpack"));
12
+ var webpack_merge_1 = require("webpack-merge");
13
+ var webpack_common_js_1 = __importDefault(require("../config/webpack.common.js"));
14
+ var runtimePath = process.cwd();
15
+ var resolve = function (dir) { return path_1.default.join(runtimePath, dir); };
16
+ var webpackConfig = (0, webpack_merge_1.merge)(webpack_common_js_1.default, {
17
+ mode: 'production',
18
+ entry: resolve('src/index.ts'),
19
+ devtool: false,
20
+ output: {
21
+ path: resolve('es'),
22
+ filename: 'index.js',
23
+ library: {
24
+ type: 'module',
25
+ },
26
+ globalObject: 'this',
27
+ },
28
+ experiments: {
29
+ outputModule: true,
30
+ },
31
+ plugins: [
32
+ new mini_css_extract_plugin_1.default({
33
+ filename: 'index.css',
34
+ }),
35
+ ],
36
+ optimization: {
37
+ minimize: true,
38
+ minimizer: [
39
+ new css_minimizer_webpack_plugin_1.default(),
40
+ new terser_webpack_plugin_1.default({
41
+ terserOptions: {
42
+ compress: {
43
+ drop_debugger: true,
44
+ },
45
+ mangle: true,
46
+ output: {
47
+ comments: false,
48
+ },
49
+ },
50
+ }),
51
+ ],
52
+ },
53
+ externals: {
54
+ moment: 'moment',
55
+ react: 'react',
56
+ 'react-dom': 'react-dom',
57
+ 'react-router-dom': 'react-router-dom',
58
+ 'prop-types': 'prop-types',
59
+ },
60
+ }, require(resolve('webpack.config.js')));
61
+ module.exports = webpackConfig;
62
+ module.exports.plugins = module.exports.plugins.filter(function (plugin) { return !(plugin instanceof html_webpack_plugin_1.default); });
63
+ module.exports.plugins = module.exports.plugins.filter(function (plugin) { return !(plugin instanceof webpack_1.default.ProvidePlugin); });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,178 @@
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
+ var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
7
+ var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
8
+ var node_polyfill_webpack_plugin_1 = __importDefault(require("node-polyfill-webpack-plugin"));
9
+ var path_1 = __importDefault(require("path"));
10
+ var webpack_1 = require("webpack");
11
+ var webpackbar_1 = __importDefault(require("webpackbar"));
12
+ var util_js_1 = __importDefault(require("../config/util.js"));
13
+ var sortSrciptTag_js_1 = __importDefault(require("../plugins/sortSrciptTag.js"));
14
+ var runtimePath = process.cwd();
15
+ var isProd = function () { return process.env.NODE_ENV === 'production'; };
16
+ var resolve = function (dir) { return path_1.default.join(runtimePath, dir); };
17
+ var tsRegex = /\.(ts|tsx)$/;
18
+ var svgRegex = /\.svg$/;
19
+ var otherRegex = /\.(woff2?|ttf)$/;
20
+ var jsRegex = /\.(js|mjs|jsx|ts|tsx)$/;
21
+ var imgRegex = /\.(jpe?g|png|gif|webp)$/;
22
+ var cssRegex = /\.css$/;
23
+ var sassRegex = /\.(scss|sass)$/;
24
+ var moduleRegex = /node_modules/;
25
+ var getStyleLoaders = function (pre) {
26
+ return [
27
+ isProd() ? mini_css_extract_plugin_1.default.loader : 'style-loader',
28
+ {
29
+ loader: 'css-loader',
30
+ options: {
31
+ url: false,
32
+ modules: {
33
+ localIdentName: '[hash:base64:5]-[local]',
34
+ },
35
+ },
36
+ },
37
+ {
38
+ loader: 'postcss-loader',
39
+ options: {
40
+ postcssOptions: {
41
+ config: util_js_1.default.getPostCssConfigPath(runtimePath),
42
+ },
43
+ },
44
+ },
45
+ pre === 'sass-loader'
46
+ ? {
47
+ loader: pre,
48
+ options: {
49
+ additionalData: "$img-prefix: '".concat(isProd() ? '../imgs' : 'imgs', "';"),
50
+ },
51
+ }
52
+ : pre
53
+ ? { loader: pre, options: {} }
54
+ : undefined,
55
+ ].filter(Boolean);
56
+ };
57
+ module.exports = {
58
+ entry: {
59
+ base: resolve('src/pages/base/main.js'),
60
+ },
61
+ output: {
62
+ path: isProd() ? resolve('dist') : void 0,
63
+ publicPath: isProd() ? './' : '/',
64
+ filename: isProd() ? 'js/[name].[contenthash:10].js' : 'js/[name].js',
65
+ chunkFilename: isProd() ? 'js/[name].[contenthash:10].chunk.js' : 'js/[name].chunk.js',
66
+ clean: true,
67
+ },
68
+ plugins: [
69
+ new html_webpack_plugin_1.default({
70
+ filename: 'base.html',
71
+ template: resolve('public/base.html'),
72
+ hash: true,
73
+ minify: {
74
+ removeAttributeQuotes: true,
75
+ },
76
+ version: Date.now(),
77
+ inject: 'body',
78
+ chunks: ['base'],
79
+ }),
80
+ new webpack_1.ProvidePlugin({
81
+ _: 'lodash',
82
+ $: 'jquery',
83
+ }),
84
+ new webpackbar_1.default({ reporters: ['profile'], profile: true }),
85
+ new node_polyfill_webpack_plugin_1.default(),
86
+ isProd() && new sortSrciptTag_js_1.default(),
87
+ ],
88
+ stats: {
89
+ assets: true,
90
+ colors: true,
91
+ errors: true,
92
+ errorDetails: true,
93
+ modules: false,
94
+ },
95
+ module: {
96
+ rules: [
97
+ {
98
+ test: cssRegex,
99
+ use: [
100
+ isProd() ? mini_css_extract_plugin_1.default.loader : 'style-loader',
101
+ 'css-loader',
102
+ {
103
+ loader: 'postcss-loader',
104
+ options: {
105
+ postcssOptions: {
106
+ config: util_js_1.default.getPostCssConfigPath(runtimePath),
107
+ },
108
+ },
109
+ },
110
+ ],
111
+ },
112
+ {
113
+ test: sassRegex,
114
+ exclude: moduleRegex,
115
+ use: getStyleLoaders('sass-loader'),
116
+ },
117
+ {
118
+ test: imgRegex,
119
+ exclude: moduleRegex,
120
+ type: 'asset',
121
+ parser: {
122
+ dataUrlCondition: {
123
+ maxSize: 20 * 1024,
124
+ },
125
+ },
126
+ },
127
+ {
128
+ test: svgRegex,
129
+ include: [resolve('src/assets')],
130
+ use: [
131
+ {
132
+ loader: 'svg-sprite-loader',
133
+ options: {
134
+ symbolId: 'icon-[name]',
135
+ },
136
+ },
137
+ ],
138
+ },
139
+ {
140
+ test: otherRegex,
141
+ exclude: moduleRegex,
142
+ type: 'asset/resource',
143
+ },
144
+ {
145
+ test: jsRegex,
146
+ exclude: moduleRegex,
147
+ use: [
148
+ {
149
+ loader: 'babel-loader',
150
+ options: {
151
+ configFile: util_js_1.default.getBabelConfigPath(runtimePath),
152
+ cacheDirectory: true,
153
+ },
154
+ },
155
+ ],
156
+ },
157
+ {
158
+ test: tsRegex,
159
+ exclude: moduleRegex,
160
+ use: [
161
+ {
162
+ loader: 'ts-loader',
163
+ options: {
164
+ configFile: resolve('tsconfig.json'),
165
+ },
166
+ },
167
+ ],
168
+ },
169
+ ],
170
+ },
171
+ resolve: {
172
+ extensions: ['.tsx', '.ts', '.js', '.jsx', '.json', '.scss', '.less'],
173
+ alias: {
174
+ '@': resolve('src'),
175
+ },
176
+ },
177
+ optimization: {},
178
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -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
+ var path_1 = __importDefault(require("path"));
7
+ var webpack_merge_1 = require("webpack-merge");
8
+ var react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
9
+ var webpack_common_js_1 = __importDefault(require("../config/webpack.common.js"));
10
+ var runtimePath = process.cwd();
11
+ var resolve = function (dir) { return path_1.default.join(runtimePath, dir); };
12
+ var webpackConfig = (0, webpack_merge_1.merge)(webpack_common_js_1.default, {
13
+ mode: 'development',
14
+ devtool: 'eval-cheap-module-source-map',
15
+ devServer: {
16
+ host: '0.0.0.0',
17
+ compress: false,
18
+ historyApiFallback: true,
19
+ client: {
20
+ overlay: false,
21
+ },
22
+ open: ['/base.html'],
23
+ hot: true,
24
+ },
25
+ plugins: [new react_refresh_webpack_plugin_1.default()],
26
+ }, require(resolve('webpack.config.js')));
27
+ module.exports = webpackConfig;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
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
+ var copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
7
+ var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
8
+ var path_1 = __importDefault(require("path"));
9
+ var webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
10
+ var webpack_merge_1 = require("webpack-merge");
11
+ var webpack_common_js_1 = __importDefault(require("../config/webpack.common.js"));
12
+ var runtimePath = process.cwd();
13
+ var resolve = function (dir) { return path_1.default.join(runtimePath, dir); };
14
+ var webpackConfig = (0, webpack_merge_1.merge)(webpack_common_js_1.default, {
15
+ mode: 'production',
16
+ devtool: false,
17
+ plugins: [
18
+ new copy_webpack_plugin_1.default({
19
+ patterns: [
20
+ {
21
+ from: resolve('public'),
22
+ to: resolve('dist'),
23
+ globOptions: {
24
+ ignore: ['**/base.html', '**/ext.html', '**/README.md'],
25
+ },
26
+ },
27
+ ],
28
+ }),
29
+ new mini_css_extract_plugin_1.default({
30
+ filename: 'css/[name].[contenthash].css',
31
+ chunkFilename: 'css/[name].[contenthash].css',
32
+ ignoreOrder: false,
33
+ }),
34
+ process.env.SPLIT === 'true' &&
35
+ new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
36
+ analyzerMode: 'server',
37
+ analyzerHost: '127.0.0.1',
38
+ analyzerPort: 48123,
39
+ openAnalyzer: true,
40
+ }),
41
+ ],
42
+ }, require(resolve('webpack.config.js')));
43
+ module.exports = webpackConfig;
Binary file
@@ -0,0 +1 @@
1
+ export {};