@xfe-repo/mini-app 0.0.6 → 0.0.7
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/config/dev.ts +29 -2
- package/config/index.ts +8 -6
- package/package.json +6 -2
package/config/dev.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { UserConfigExport } from "@tarojs/cli";
|
|
2
|
+
import RoutesDefineWebpackPlugin from "@xfe-repo/routes-define-webpack-plugin";
|
|
3
|
+
import { appProjectSrcPath } from ".";
|
|
2
4
|
|
|
3
5
|
export default {
|
|
4
6
|
env: {
|
|
@@ -8,6 +10,31 @@ export default {
|
|
|
8
10
|
quiet: false,
|
|
9
11
|
stats: true
|
|
10
12
|
},
|
|
11
|
-
mini: {
|
|
12
|
-
|
|
13
|
+
mini: {
|
|
14
|
+
webpackChain(chain) {
|
|
15
|
+
// 生成路由定义文件
|
|
16
|
+
chain.plugin('routesDefine').use(RoutesDefineWebpackPlugin, [
|
|
17
|
+
{
|
|
18
|
+
routePrefix: 'pages',
|
|
19
|
+
routeSuffix: 'index',
|
|
20
|
+
outputPath: appProjectSrcPath,
|
|
21
|
+
},
|
|
22
|
+
])
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
h5: {
|
|
26
|
+
webpackChain(chain) {
|
|
27
|
+
// 生成路由定义文件
|
|
28
|
+
chain.plugin('routesDefine').use(RoutesDefineWebpackPlugin, [
|
|
29
|
+
{
|
|
30
|
+
routePrefix: 'pages',
|
|
31
|
+
routeSuffix: 'index',
|
|
32
|
+
outputPath: appProjectSrcPath,
|
|
33
|
+
},
|
|
34
|
+
])
|
|
35
|
+
},
|
|
36
|
+
devServer: {
|
|
37
|
+
port: 9000,
|
|
38
|
+
}
|
|
39
|
+
},
|
|
13
40
|
} satisfies UserConfigExport<'webpack5'>
|
package/config/index.ts
CHANGED
|
@@ -5,10 +5,12 @@ import devConfig from './dev'
|
|
|
5
5
|
import prodConfig from './prod'
|
|
6
6
|
|
|
7
7
|
// 获取APP_PROJECT_ROOT相对于当前文件的路径
|
|
8
|
-
const appProjectRootRelPath = path.relative(path.join(__dirname, '..'), process.env.APP_PROJECT_ROOT || '')
|
|
8
|
+
export const appProjectRootRelPath = path.relative(path.join(__dirname, '..'), process.env.APP_PROJECT_ROOT || '')
|
|
9
|
+
export const appProjectSrcPath = path.join(appProjectRootRelPath, 'src')
|
|
10
|
+
export const appProjectDistPath = path.join(appProjectRootRelPath, 'dist')
|
|
9
11
|
|
|
10
12
|
// 获取API_ENV环境变量 此处注意 需要stringify为带引号的字符串 这样在webpack中才能正确解析
|
|
11
|
-
const API_ENV = JSON.stringify(process.env.API_ENV || '')
|
|
13
|
+
export const API_ENV = JSON.stringify(process.env.API_ENV || '')
|
|
12
14
|
|
|
13
15
|
export default defineConfig<'webpack5'>(async (merge) => {
|
|
14
16
|
const baseConfig: UserConfigExport<'webpack5'> = {
|
|
@@ -21,10 +23,10 @@ export default defineConfig<'webpack5'>(async (merge) => {
|
|
|
21
23
|
375: 2,
|
|
22
24
|
828: 1.81 / 2
|
|
23
25
|
},
|
|
24
|
-
sourceRoot:
|
|
25
|
-
outputRoot:
|
|
26
|
+
sourceRoot: appProjectSrcPath,
|
|
27
|
+
outputRoot: appProjectDistPath,
|
|
26
28
|
env: {
|
|
27
|
-
API_ENV
|
|
29
|
+
API_ENV
|
|
28
30
|
},
|
|
29
31
|
alias: {
|
|
30
32
|
react: path.resolve(appProjectRootRelPath, './node_modules/react')
|
|
@@ -91,7 +93,7 @@ export default defineConfig<'webpack5'>(async (merge) => {
|
|
|
91
93
|
appName: 'xfe-mini',
|
|
92
94
|
postcss: {
|
|
93
95
|
cssModules: {
|
|
94
|
-
enable: true
|
|
96
|
+
enable: true // 默认为 false,如需使用 css modules 功能,则设为 true
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfe-repo/mini-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"bin": {
|
|
5
5
|
"xfe-mini": "./bin/index.js"
|
|
6
6
|
},
|
|
@@ -50,12 +50,16 @@
|
|
|
50
50
|
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
|
51
51
|
"typescript": "^5.4.5",
|
|
52
52
|
"webpack": "5.91.0",
|
|
53
|
-
"yaml": "^2.3.4"
|
|
53
|
+
"yaml": "^2.3.4",
|
|
54
|
+
"@xfe-repo/routes-define-webpack-plugin": "0.0.2"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
57
|
"react": "18.2.0",
|
|
57
58
|
"react-dom": "18.2.0"
|
|
58
59
|
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"registry": "https://registry.npmjs.org/"
|
|
62
|
+
},
|
|
59
63
|
"scripts": {
|
|
60
64
|
"build": "tsup",
|
|
61
65
|
"dev": "tsup --watch",
|