swico 0.8.1-beta18 → 0.8.1-beta2
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 +1 -1
- package/src/command/build.js +4 -1
- package/src/command/start.js +4 -28
- package/src/config/webpack.base.react.js +6 -0
- package/src/config/webpack.base.vue.js +6 -0
- package/src/config/webpack.prod.js +2 -10
- package/src/utils/tools.d.ts +0 -2
- package/src/utils/tools.js +4 -10
package/package.json
CHANGED
package/src/command/build.js
CHANGED
|
@@ -42,8 +42,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
var webpack_1 = __importDefault(require("webpack"));
|
|
43
43
|
var webpack_prod_1 = __importDefault(require("../config/webpack.prod"));
|
|
44
44
|
var config_1 = require("../utils/config");
|
|
45
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
46
|
+
var ora_1 = __importDefault(require("ora"));
|
|
45
47
|
var tools_1 = require("../utils/tools");
|
|
46
48
|
var package_json_1 = __importDefault(require("../../package.json"));
|
|
49
|
+
var spinner = (0, ora_1.default)();
|
|
47
50
|
function default_1() {
|
|
48
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
49
52
|
var projectConfig, entryPath, templatePath, projectPath, customConfig, templateType, buildConfig, compiler;
|
|
@@ -83,7 +86,7 @@ function default_1() {
|
|
|
83
86
|
if (stats.hasWarnings()) {
|
|
84
87
|
tools_1.toast.warning(info.warnings.map(function (item) { return item.stack; }));
|
|
85
88
|
}
|
|
86
|
-
|
|
89
|
+
spinner.succeed("".concat(chalk_1.default.green.bold('Building complete'), " \n"));
|
|
87
90
|
});
|
|
88
91
|
return [2];
|
|
89
92
|
}
|
package/src/command/start.js
CHANGED
|
@@ -60,7 +60,6 @@ var path_1 = __importDefault(require("path"));
|
|
|
60
60
|
var cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
61
61
|
var _a = process.env, envPort = _a.PORT, RESTART = _a.RESTART;
|
|
62
62
|
var package_json_1 = __importDefault(require("../../package.json"));
|
|
63
|
-
var chalk_1 = __importDefault(require("chalk"));
|
|
64
63
|
var handleWatch = function (projectPath, devServer) {
|
|
65
64
|
var configFilesWatcher = chokidar_1.default
|
|
66
65
|
.watch([
|
|
@@ -123,16 +122,9 @@ var restartServer = function () {
|
|
|
123
122
|
process.exit(1);
|
|
124
123
|
}
|
|
125
124
|
};
|
|
126
|
-
var getMockGetLogger = function (compiler) {
|
|
127
|
-
var logger = compiler.getInfrastructureLogger('name');
|
|
128
|
-
var log = logger.log, debug = logger.debug, error = logger.error, warn = logger.warn;
|
|
129
|
-
return function (name) {
|
|
130
|
-
return __assign(__assign({}, logger), { log: log, debug: debug, error: error, warn: warn, info: function () { } });
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
125
|
function start() {
|
|
134
126
|
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
-
var _a, projectConfig, projectPath, startConfig, compiler,
|
|
127
|
+
var _a, projectConfig, projectPath, startConfig, compiler, devServer, oriConsoleLog, e_1, strErr;
|
|
136
128
|
return __generator(this, function (_b) {
|
|
137
129
|
switch (_b.label) {
|
|
138
130
|
case 0:
|
|
@@ -161,33 +153,17 @@ function start() {
|
|
|
161
153
|
case 6:
|
|
162
154
|
startConfig = _b.sent();
|
|
163
155
|
compiler = (0, webpack_1.default)(startConfig);
|
|
164
|
-
oriLogger = compiler.getInfrastructureLogger;
|
|
165
|
-
compiler.getInfrastructureLogger = getMockGetLogger(compiler);
|
|
166
156
|
devServer = new webpack_dev_server_1.default(__assign(__assign({}, startConfig.devServer), { port: availablePort }), compiler);
|
|
167
|
-
compiler.watch({}, function (err, stats) {
|
|
168
|
-
if (err) {
|
|
169
|
-
tools_1.toast.error(err.stack || err.toString());
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
var info = stats.toJson();
|
|
173
|
-
if (stats.hasErrors()) {
|
|
174
|
-
tools_1.toast.error(info.errors.map(function (item) { return item.stack; }));
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if (stats.hasWarnings()) {
|
|
178
|
-
tools_1.toast.warning(info.warnings.map(function (item) { return item.stack; }));
|
|
179
|
-
}
|
|
180
|
-
tools_1.toast.info("Compiled successfully in ".concat(info.time));
|
|
181
|
-
});
|
|
182
157
|
_b.label = 7;
|
|
183
158
|
case 7:
|
|
184
159
|
_b.trys.push([7, 9, , 10]);
|
|
160
|
+
oriConsoleLog = console.log;
|
|
161
|
+
console.log = function () { };
|
|
185
162
|
return [4, devServer.start()];
|
|
186
163
|
case 8:
|
|
187
164
|
_b.sent();
|
|
188
|
-
|
|
165
|
+
console.log = oriConsoleLog;
|
|
189
166
|
handleWatch(projectPath, devServer);
|
|
190
|
-
tools_1.toast.info("Project is running at\uFF1A".concat(chalk_1.default.hex('#29abe0')("".concat(startConfig.devServer.server, "://localhost:").concat(availablePort, "/"))));
|
|
191
167
|
return [3, 10];
|
|
192
168
|
case 9:
|
|
193
169
|
e_1 = _b.sent();
|
|
@@ -62,6 +62,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
62
62
|
var path_1 = __importDefault(require("path"));
|
|
63
63
|
var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
64
64
|
var config_1 = require("../utils/config");
|
|
65
|
+
var webpackbar_1 = __importDefault(require("webpackbar"));
|
|
65
66
|
var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
66
67
|
var fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
67
68
|
var webpack_1 = __importDefault(require("webpack"));
|
|
@@ -270,6 +271,11 @@ function default_1(_a) {
|
|
|
270
271
|
new mini_css_extract_plugin_1.default({
|
|
271
272
|
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
272
273
|
ignoreOrder: true
|
|
274
|
+
}),
|
|
275
|
+
new webpackbar_1.default({
|
|
276
|
+
name: 'Swico',
|
|
277
|
+
color: '#5f72f5',
|
|
278
|
+
profile: false
|
|
273
279
|
})
|
|
274
280
|
], false), ((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins), true)
|
|
275
281
|
}];
|
|
@@ -62,6 +62,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
62
62
|
var path_1 = __importDefault(require("path"));
|
|
63
63
|
var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
64
64
|
var config_1 = require("../utils/config");
|
|
65
|
+
var webpackbar_1 = __importDefault(require("webpackbar"));
|
|
65
66
|
var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
66
67
|
var fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
67
68
|
var webpack_1 = __importDefault(require("webpack"));
|
|
@@ -287,6 +288,11 @@ function default_1(_a) {
|
|
|
287
288
|
new mini_css_extract_plugin_1.default({
|
|
288
289
|
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
289
290
|
ignoreOrder: true
|
|
291
|
+
}),
|
|
292
|
+
new webpackbar_1.default({
|
|
293
|
+
name: 'Swico',
|
|
294
|
+
color: '#5f72f5',
|
|
295
|
+
profile: false
|
|
290
296
|
})
|
|
291
297
|
], false), ((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins), true)
|
|
292
298
|
}];
|
|
@@ -89,8 +89,6 @@ var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
89
89
|
var config_1 = require("../utils/config");
|
|
90
90
|
var webpack_merge_1 = require("webpack-merge");
|
|
91
91
|
var esbuild_loader_1 = require("esbuild-loader");
|
|
92
|
-
var webpackbar_1 = __importDefault(require("webpackbar"));
|
|
93
|
-
var tools_1 = require("../utils/tools");
|
|
94
92
|
var BundleAnalyzerPlugin = webpack_bundle_analyzer_1.default.BundleAnalyzerPlugin;
|
|
95
93
|
var isAnalyze = process.env.ANALYZE === 'true';
|
|
96
94
|
function default_1(options) {
|
|
@@ -157,7 +155,7 @@ function default_1(options) {
|
|
|
157
155
|
}
|
|
158
156
|
}
|
|
159
157
|
},
|
|
160
|
-
plugins: __spreadArray(__spreadArray(__spreadArray(
|
|
158
|
+
plugins: __spreadArray(__spreadArray(__spreadArray([], (isPublicDirExist || copyConfig.length > 0
|
|
161
159
|
? [
|
|
162
160
|
new copy_webpack_plugin_1.default({
|
|
163
161
|
patterns: __spreadArray(__spreadArray([], (isPublicDirExist ? [path_1.default.join(projectPath, '/public')] : []), true), copyConfig, true)
|
|
@@ -178,13 +176,7 @@ function default_1(options) {
|
|
|
178
176
|
logLevel: 'info'
|
|
179
177
|
})
|
|
180
178
|
]
|
|
181
|
-
: []), true), [
|
|
182
|
-
new webpackbar_1.default({
|
|
183
|
-
name: 'Swico',
|
|
184
|
-
color: tools_1.themeColor,
|
|
185
|
-
profile: false
|
|
186
|
-
})
|
|
187
|
-
], false), ((_g = (_f = customConfig.prod) === null || _f === void 0 ? void 0 : _f.plugins) !== null && _g !== void 0 ? _g : []), true)
|
|
179
|
+
: []), true), ((_g = (_f = customConfig.prod) === null || _f === void 0 ? void 0 : _f.plugins) !== null && _g !== void 0 ? _g : []), true)
|
|
188
180
|
})];
|
|
189
181
|
}
|
|
190
182
|
});
|
package/src/utils/tools.d.ts
CHANGED
|
@@ -2,10 +2,8 @@ import { ConfigRouterType } from './config';
|
|
|
2
2
|
export declare const copyDirFiles: (src: any, dest: any, filter?: (fileName: any) => boolean) => Promise<void>;
|
|
3
3
|
export declare const getFormatRouter: (projectPath: string, routes: ConfigRouterType['routes'], templateType: any) => any[];
|
|
4
4
|
export declare const getPort: () => Promise<number>;
|
|
5
|
-
export declare const themeColor = "#7888FCFF";
|
|
6
5
|
export declare const toast: {
|
|
7
6
|
info: (message: string) => void;
|
|
8
|
-
success: (message: string) => void;
|
|
9
7
|
error: (message: string | string[]) => void;
|
|
10
8
|
warning: (message: string | string[]) => void;
|
|
11
9
|
};
|
package/src/utils/tools.js
CHANGED
|
@@ -80,14 +80,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
80
80
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
81
81
|
};
|
|
82
82
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
83
|
-
exports.initIndexFile = exports.toast = exports.
|
|
83
|
+
exports.initIndexFile = exports.toast = exports.getPort = exports.getFormatRouter = exports.copyDirFiles = void 0;
|
|
84
84
|
var portfinder_1 = __importDefault(require("portfinder"));
|
|
85
85
|
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
86
86
|
var path_1 = __importDefault(require("path"));
|
|
87
87
|
var chalk_1 = __importDefault(require("chalk"));
|
|
88
88
|
var process = __importStar(require("process"));
|
|
89
|
-
var ora_1 = __importDefault(require("ora"));
|
|
90
|
-
var spinner = (0, ora_1.default)();
|
|
91
89
|
var copyDirFiles = function (src, dest, filter) { return __awaiter(void 0, void 0, void 0, function () {
|
|
92
90
|
var _copy, e_1;
|
|
93
91
|
return __generator(this, function (_a) {
|
|
@@ -206,16 +204,12 @@ var getPort = function () {
|
|
|
206
204
|
});
|
|
207
205
|
};
|
|
208
206
|
exports.getPort = getPort;
|
|
209
|
-
exports.themeColor = '#7888FCFF';
|
|
210
207
|
exports.toast = {
|
|
211
208
|
info: function (message) {
|
|
212
|
-
console.log("> ".concat(chalk_1.default.hex(
|
|
213
|
-
},
|
|
214
|
-
success: function (message) {
|
|
215
|
-
console.log("> ".concat(chalk_1.default.hex('#32f264')(message), "\n"));
|
|
209
|
+
console.log("> ".concat(chalk_1.default.hex('#5f72f5')(message), "\n"));
|
|
216
210
|
},
|
|
217
211
|
error: function (message) {
|
|
218
|
-
console.log("\n> ".concat(chalk_1.default.hex(
|
|
212
|
+
console.log("\n> ".concat(chalk_1.default.hex('#5f72f5')('There are some errors about Swico:'), " \n"));
|
|
219
213
|
if (Array.isArray(message)) {
|
|
220
214
|
message.forEach(function (item) {
|
|
221
215
|
console.log(" > ".concat(chalk_1.default.red.bold(item), " \n"));
|
|
@@ -226,7 +220,7 @@ exports.toast = {
|
|
|
226
220
|
}
|
|
227
221
|
},
|
|
228
222
|
warning: function (message) {
|
|
229
|
-
console.log("\n> ".concat(chalk_1.default.hex(
|
|
223
|
+
console.log("\n> ".concat(chalk_1.default.hex('#5f72f5')('There are some warnings about Swico:'), " \n"));
|
|
230
224
|
if (Array.isArray(message)) {
|
|
231
225
|
message.forEach(function (item) {
|
|
232
226
|
console.log(" > ".concat(chalk_1.default.hex('#fb8918').bold(item), " \n"));
|