@sepveneto/plugin-mp-router-view 0.3.4 → 0.4.0
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/README.md +19 -0
- package/dist/{chunk-TUTSLW5Q.js → chunk-2YITRCW5.js} +6 -2
- package/dist/esbuild.cjs +2 -2
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/loader.cjs +37207 -0
- package/dist/loader.d.ts +3 -0
- package/dist/loader.js +21 -0
- package/dist/rollup.cjs +2 -2
- package/dist/rollup.js +1 -1
- package/dist/vite.cjs +2 -2
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +2 -2
- package/dist/webpack.js +1 -1
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -18,6 +18,25 @@ pnpm i @sepveneto/plugin-mp-router-view
|
|
|
18
18
|
|
|
19
19
|
### 使用
|
|
20
20
|
|
|
21
|
+
<details>
|
|
22
|
+
<summary>UniApp v2</summary><br>
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
module.exports = {
|
|
26
|
+
chainWebpack: config => {
|
|
27
|
+
config.module
|
|
28
|
+
.rule('vue')
|
|
29
|
+
.use('@sepveneto/plugin-mp-router-view/loader')
|
|
30
|
+
.loader('@sepveneto/plugin-mp-router-view/loader')
|
|
31
|
+
.options({ /* options */ })
|
|
32
|
+
.end()
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
#### 为什么
|
|
37
|
+
虽然uniapp的v2版本是依赖`webpack4/5`进行构建,但是通过`plugins`注入的代码无法影响到uniapp的编译结果。因此参考[uniapp-router-view-loader](https://github.com/2460392754/uniapp-router-view-loader)使用loader来实现vue2版本的代码注入。
|
|
38
|
+
<br></details>
|
|
39
|
+
|
|
21
40
|
<details>
|
|
22
41
|
<summary>Vite</summary><br>
|
|
23
42
|
|
|
@@ -37086,12 +37086,12 @@ function getTemplate(code) {
|
|
|
37086
37086
|
};
|
|
37087
37087
|
}
|
|
37088
37088
|
function addToHeader(code, header2) {
|
|
37089
|
-
return code.replace(/<
|
|
37089
|
+
return code.replace(/<template(.*?)>/, (p) => {
|
|
37090
37090
|
return p + header2;
|
|
37091
37091
|
});
|
|
37092
37092
|
}
|
|
37093
37093
|
function addToFooter(code, footer2) {
|
|
37094
|
-
return code.replace(/(
|
|
37094
|
+
return code.replace(/(\s*)(<\/template>)(?!(([\s\S]*)(<\/template>)))/, (p) => footer2 + p);
|
|
37095
37095
|
}
|
|
37096
37096
|
function getPages(collectMode) {
|
|
37097
37097
|
const jsonStr = fs.readFileSync(path2.resolve(INPUT_DIR, "pages.json"), "utf-8");
|
|
@@ -37174,6 +37174,10 @@ var unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
|
37174
37174
|
var src_default = unplugin;
|
|
37175
37175
|
|
|
37176
37176
|
export {
|
|
37177
|
+
isAppVue,
|
|
37178
|
+
isEntryPage,
|
|
37179
|
+
getPages,
|
|
37180
|
+
transform2 as transform,
|
|
37177
37181
|
NAME,
|
|
37178
37182
|
unpluginFactory,
|
|
37179
37183
|
unplugin,
|
package/dist/esbuild.cjs
CHANGED
|
@@ -37116,12 +37116,12 @@ function getTemplate(code) {
|
|
|
37116
37116
|
};
|
|
37117
37117
|
}
|
|
37118
37118
|
function addToHeader(code, header2) {
|
|
37119
|
-
return code.replace(/<
|
|
37119
|
+
return code.replace(/<template(.*?)>/, (p) => {
|
|
37120
37120
|
return p + header2;
|
|
37121
37121
|
});
|
|
37122
37122
|
}
|
|
37123
37123
|
function addToFooter(code, footer2) {
|
|
37124
|
-
return code.replace(/(
|
|
37124
|
+
return code.replace(/(\s*)(<\/template>)(?!(([\s\S]*)(<\/template>)))/, (p) => footer2 + p);
|
|
37125
37125
|
}
|
|
37126
37126
|
function getPages(collectMode) {
|
|
37127
37127
|
const jsonStr = import_node_fs.default.readFileSync(import_node_path.default.resolve(INPUT_DIR, "pages.json"), "utf-8");
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -37116,12 +37116,12 @@ function getTemplate(code) {
|
|
|
37116
37116
|
};
|
|
37117
37117
|
}
|
|
37118
37118
|
function addToHeader(code, header2) {
|
|
37119
|
-
return code.replace(/<
|
|
37119
|
+
return code.replace(/<template(.*?)>/, (p) => {
|
|
37120
37120
|
return p + header2;
|
|
37121
37121
|
});
|
|
37122
37122
|
}
|
|
37123
37123
|
function addToFooter(code, footer2) {
|
|
37124
|
-
return code.replace(/(
|
|
37124
|
+
return code.replace(/(\s*)(<\/template>)(?!(([\s\S]*)(<\/template>)))/, (p) => footer2 + p);
|
|
37125
37125
|
}
|
|
37126
37126
|
function getPages(collectMode) {
|
|
37127
37127
|
const jsonStr = import_node_fs.default.readFileSync(import_node_path.default.resolve(INPUT_DIR, "pages.json"), "utf-8");
|