@codelet/cli-service 0.0.12 → 0.0.13
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/dist/config.d.ts +3 -1
- package/dist/config.js +14 -3
- package/dist/defineConfig.js +1 -2
- package/dist/utils.js +5 -5
- package/package.json +3 -2
package/dist/config.d.ts
CHANGED
|
@@ -6,9 +6,11 @@ export interface Config {
|
|
|
6
6
|
source?: string[];
|
|
7
7
|
/** 第一页 */
|
|
8
8
|
pageIndex?: string;
|
|
9
|
+
/** 静态文件 */
|
|
10
|
+
publicDir?: string;
|
|
9
11
|
/** webpack 配置 */
|
|
10
12
|
webpack?: Configuration;
|
|
11
13
|
}
|
|
12
|
-
export declare function getDefaultConfig(options?:
|
|
14
|
+
export declare function getDefaultConfig(options?: Omit<Config, 'webpack'> & {
|
|
13
15
|
isDev?: boolean;
|
|
14
16
|
}): Required<Config>;
|
package/dist/config.js
CHANGED
|
@@ -3,18 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getDefaultConfig =
|
|
6
|
+
exports.getDefaultConfig = getDefaultConfig;
|
|
7
7
|
const app_json_webpack_plugin_1 = __importDefault(require("@codelet/app-json-webpack-plugin"));
|
|
8
8
|
const hmr_webpack_plugin_1 = __importDefault(require("@codelet/hmr-webpack-plugin"));
|
|
9
9
|
const inject_chunk_webpack_plugin_1 = __importDefault(require("@codelet/inject-chunk-webpack-plugin"));
|
|
10
10
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
11
11
|
const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
|
|
12
|
+
const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
|
|
12
13
|
const webpackbar_1 = __importDefault(require("webpackbar"));
|
|
13
14
|
const utils_1 = require("./utils");
|
|
14
15
|
function getDefaultConfig(options) {
|
|
15
|
-
const { entryPath, source, pageIndex, isDev } = Object.assign({
|
|
16
|
+
const { entryPath, source, pageIndex, publicDir, isDev } = Object.assign({
|
|
16
17
|
isDev: false,
|
|
17
18
|
pageIndex: '',
|
|
19
|
+
publicDir: 'public',
|
|
18
20
|
entryPath: './src',
|
|
19
21
|
source: ['app.(js|ts)', 'pages/**/*.(js|ts)', 'components/**/*.(js|ts)'],
|
|
20
22
|
}, options);
|
|
@@ -29,6 +31,15 @@ function getDefaultConfig(options) {
|
|
|
29
31
|
new app_json_webpack_plugin_1.default({
|
|
30
32
|
pageIndex,
|
|
31
33
|
}),
|
|
34
|
+
new copy_webpack_plugin_1.default({
|
|
35
|
+
patterns: [
|
|
36
|
+
{
|
|
37
|
+
from: publicDir, // 源目录
|
|
38
|
+
to: './', // 复制到输出目录(dist)的根路径
|
|
39
|
+
noErrorOnMissing: true, // 若 public 目录不存在时不报错
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
}),
|
|
32
43
|
new webpackbar_1.default(),
|
|
33
44
|
];
|
|
34
45
|
if (isDev) {
|
|
@@ -68,6 +79,7 @@ function getDefaultConfig(options) {
|
|
|
68
79
|
pageIndex,
|
|
69
80
|
entryPath,
|
|
70
81
|
source,
|
|
82
|
+
publicDir,
|
|
71
83
|
webpack: {
|
|
72
84
|
mode,
|
|
73
85
|
devtool: false,
|
|
@@ -141,4 +153,3 @@ function getDefaultConfig(options) {
|
|
|
141
153
|
},
|
|
142
154
|
};
|
|
143
155
|
}
|
|
144
|
-
exports.getDefaultConfig = getDefaultConfig;
|
package/dist/defineConfig.js
CHANGED
package/dist/utils.js
CHANGED
|
@@ -3,7 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.parseDir = exports.resolve = exports.cmd = void 0;
|
|
7
|
+
exports.getOptionValue = getOptionValue;
|
|
8
|
+
exports.parseArgv = parseArgv;
|
|
9
|
+
exports.getConfig = getConfig;
|
|
7
10
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
8
11
|
const fs_1 = __importDefault(require("fs"));
|
|
9
12
|
const path_1 = __importDefault(require("path"));
|
|
@@ -14,7 +17,7 @@ const resolve = (...args) => path_1.default.resolve(exports.cmd, ...args);
|
|
|
14
17
|
exports.resolve = resolve;
|
|
15
18
|
const parseDir = (entryPath, source) => {
|
|
16
19
|
entryPath = (0, exports.resolve)(entryPath);
|
|
17
|
-
const filepaths = fast_glob_1.default.sync(source.map((item) => (0, exports.resolve)(entryPath, item)));
|
|
20
|
+
const filepaths = fast_glob_1.default.sync(source.map((item) => (0, exports.resolve)(entryPath, item).replace(/\\/g, '/')));
|
|
18
21
|
const entry = filepaths.reduce((res, filepath) => {
|
|
19
22
|
const relPath = path_1.default.relative(entryPath, filepath);
|
|
20
23
|
const { dir, name } = path_1.default.parse(relPath);
|
|
@@ -33,7 +36,6 @@ function getOptionValue(argv, option) {
|
|
|
33
36
|
return argv[index + 1];
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
|
-
exports.getOptionValue = getOptionValue;
|
|
37
39
|
function parseArgv(argv) {
|
|
38
40
|
const isWatch = argv.includes('--watch');
|
|
39
41
|
const isDev = argv.includes('dev');
|
|
@@ -42,7 +44,6 @@ function parseArgv(argv) {
|
|
|
42
44
|
const configPath = (0, exports.resolve)(configRelativePath);
|
|
43
45
|
return { configPath, isWatch, pageIndex, isDev };
|
|
44
46
|
}
|
|
45
|
-
exports.parseArgv = parseArgv;
|
|
46
47
|
function getConfig(options) {
|
|
47
48
|
const { configPath, isWatch } = options;
|
|
48
49
|
let config;
|
|
@@ -80,4 +81,3 @@ function getConfig(options) {
|
|
|
80
81
|
}
|
|
81
82
|
return webpack;
|
|
82
83
|
}
|
|
83
|
-
exports.getConfig = getConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codelet/cli-service",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "cli-service",
|
|
5
5
|
"bin": {
|
|
6
6
|
"codelet-cli-service": "./bin/codelet-cli-service.js"
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@babel/preset-env": "^7.23.8",
|
|
32
32
|
"@babel/preset-typescript": "^7.23.3",
|
|
33
33
|
"babel-loader": "^9.1.3",
|
|
34
|
+
"copy-webpack-plugin": "^13.0.1",
|
|
34
35
|
"css-loader": "^6.9.0",
|
|
35
36
|
"fast-glob": "^3.3.2",
|
|
36
37
|
"mini-css-extract-plugin": "^2.7.7",
|
|
@@ -40,9 +41,9 @@
|
|
|
40
41
|
"webpack": "5.89.0",
|
|
41
42
|
"webpack-merge": "^5.10.0",
|
|
42
43
|
"webpackbar": "^6.0.0",
|
|
44
|
+
"@codelet/inject-chunk-webpack-plugin": "^0.0.7",
|
|
43
45
|
"@codelet/app-json-webpack-plugin": "^0.0.7",
|
|
44
46
|
"@codelet/hmr-webpack-plugin": "^0.0.2",
|
|
45
|
-
"@codelet/inject-chunk-webpack-plugin": "^0.0.7",
|
|
46
47
|
"@codelet/copy-loader": "^0.0.7",
|
|
47
48
|
"@codelet/wxml-loader": "^0.0.9"
|
|
48
49
|
},
|