@dcloudio/vue-cli-plugin-uni 2.0.2-alpha-3061520221220001 → 2.0.2-alpha-3061520221222001
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/lib/mp/index.js +47 -46
- package/package.json +3 -3
package/lib/mp/index.js
CHANGED
|
@@ -9,7 +9,9 @@ const {
|
|
|
9
9
|
getPlatformCssnano,
|
|
10
10
|
getPlatformStat,
|
|
11
11
|
getPlatformPush,
|
|
12
|
-
getPlatformUniCloud
|
|
12
|
+
getPlatformUniCloud,
|
|
13
|
+
createSource,
|
|
14
|
+
deleteAsset
|
|
13
15
|
} = require('@dcloudio/uni-cli-shared')
|
|
14
16
|
|
|
15
17
|
const WebpackUniAppPlugin = require('../../packages/webpack-uni-app-loader/plugin/index')
|
|
@@ -26,7 +28,7 @@ function createUniMPPlugin () {
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
const createWxMpIndependentPlugins = require('@dcloudio/uni-mp-weixin/lib/createIndependentPlugin')
|
|
29
|
-
|
|
31
|
+
|
|
30
32
|
const UniTips = require('./tips')
|
|
31
33
|
|
|
32
34
|
function getProvides () {
|
|
@@ -77,62 +79,61 @@ function getProvides () {
|
|
|
77
79
|
return provides
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
function processWxss (name, assets) {
|
|
82
|
+
function processWxss (compilation, name, assets) {
|
|
81
83
|
const dirname = path.dirname(name)
|
|
82
84
|
const mainWxssCode = `@import "${normalizePath(path.relative(dirname, 'common/main.wxss'))}";`
|
|
83
85
|
const code = `${mainWxssCode}` + assets[name].source().toString()
|
|
84
|
-
|
|
85
|
-
size () {
|
|
86
|
-
return Buffer.byteLength(code, 'utf8')
|
|
87
|
-
},
|
|
88
|
-
source () {
|
|
89
|
-
return code
|
|
90
|
-
}
|
|
91
|
-
}
|
|
86
|
+
compilation.updateAsset(name, createSource(code))
|
|
92
87
|
}
|
|
93
88
|
|
|
94
89
|
const parseRequirePath = path => path.startsWith('common') ? `./${path}` : path
|
|
95
90
|
|
|
96
|
-
function procssJs (name, assets, hasVendor) {
|
|
91
|
+
function procssJs (compilation, name, assets, hasVendor) {
|
|
97
92
|
const dirname = path.dirname(name)
|
|
98
93
|
const runtimeJsCode = `require('${normalizePath(parseRequirePath(path.relative(dirname, 'common/runtime.js')))}');`
|
|
99
94
|
const vendorJsCode = hasVendor
|
|
100
95
|
? `require('${normalizePath(parseRequirePath(path.relative(dirname, 'common/vendor.js')))}');` : ''
|
|
101
96
|
const mainJsCode = `require('${normalizePath(parseRequirePath(path.relative(dirname, 'common/main.js')))}');`
|
|
102
97
|
const code = `${runtimeJsCode}${vendorJsCode}${mainJsCode}` + assets[name].source().toString()
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
compilation.updateAsset(name, createSource(code))
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function processAssets (compilation) {
|
|
102
|
+
const assets = compilation.assets
|
|
103
|
+
const hasMainWxss = assets['common/main.wxss']
|
|
104
|
+
const hasVendor = assets['common/vendor.js']
|
|
105
|
+
Object.keys(assets).forEach(name => {
|
|
106
|
+
if (name.startsWith('common')) {
|
|
107
|
+
return
|
|
109
108
|
}
|
|
110
|
-
|
|
109
|
+
const extname = path.extname(name)
|
|
110
|
+
if (extname === '.wxss' && hasMainWxss && process.UNI_ENTRY[name.replace(extname, '')]) {
|
|
111
|
+
processWxss(compilation, name, assets)
|
|
112
|
+
} else if (extname === '.js') {
|
|
113
|
+
procssJs(compilation, name, assets, hasVendor)
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
// delete assets['common/main.js']
|
|
117
|
+
deleteAsset(compilation, 'app.js')
|
|
118
|
+
deleteAsset(compilation, 'app.json')
|
|
119
|
+
deleteAsset(compilation, 'app.wxss')
|
|
120
|
+
deleteAsset(compilation, 'project.config.json')
|
|
111
121
|
}
|
|
112
122
|
|
|
113
123
|
class PreprocessAssetsPlugin {
|
|
114
124
|
apply (compiler) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
const extname = path.extname(name)
|
|
124
|
-
if (extname === '.wxss' && hasMainWxss && process.UNI_ENTRY[name.replace(extname, '')]) {
|
|
125
|
-
processWxss(name, assets)
|
|
126
|
-
} else if (extname === '.js') {
|
|
127
|
-
procssJs(name, assets, hasVendor)
|
|
128
|
-
}
|
|
125
|
+
if (webpack.version[0] > 4) {
|
|
126
|
+
compiler.hooks.compilation.tap('PreprocessAssetsPlugin', compilation => {
|
|
127
|
+
compilation.hooks.processAssets.tap({
|
|
128
|
+
name: 'PreprocessAssetsPlugin',
|
|
129
|
+
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
|
|
130
|
+
}, (_) => {
|
|
131
|
+
processAssets(compilation)
|
|
132
|
+
})
|
|
129
133
|
})
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
delete assets['app.wxss']
|
|
134
|
-
delete assets['project.config.json']
|
|
135
|
-
})
|
|
134
|
+
} else {
|
|
135
|
+
compiler.hooks.emit.tap('PreprocessAssetsPlugin', (compilation) => processAssets(compilation))
|
|
136
|
+
}
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
|
|
@@ -143,7 +144,7 @@ function initSubpackageConfig (webpackConfig, vueOptions) {
|
|
|
143
144
|
}
|
|
144
145
|
vueOptions.outputDir = process.env.UNI_OUTPUT_DIR
|
|
145
146
|
webpackConfig.output.path(process.env.UNI_OUTPUT_DIR)
|
|
146
|
-
webpackConfig.output.
|
|
147
|
+
webpackConfig.output.set(webpack.version[0] > 4 ? 'chunkLoadingGlobal' : 'jsonpFunction', 'webpackJsonp_' + (process.env.UNI_SUBPACKGE || process.env.UNI_MP_PLUGIN))
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
function addToUniEntry (fileName) {
|
|
@@ -192,7 +193,7 @@ module.exports = {
|
|
|
192
193
|
|
|
193
194
|
if ((process.env.UNI_SUBPACKGE || process.env.UNI_MP_PLUGIN) && process.env.UNI_SUBPACKGE !== 'main') {
|
|
194
195
|
plugins.push(new PreprocessAssetsPlugin())
|
|
195
|
-
}
|
|
196
|
+
}
|
|
196
197
|
|
|
197
198
|
{
|
|
198
199
|
const globalEnv = process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'wx';
|
|
@@ -230,11 +231,11 @@ ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__ = __webpack_require__;`
|
|
|
230
231
|
}
|
|
231
232
|
if (process.env.NODE_ENV === 'production' || process.env.UNI_MINIMIZE === 'true') {
|
|
232
233
|
output.pathinfo = false
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (process.env.UNI_PLATFORM === 'mp-weixin' && process.env.NODE_ENV === 'production') {
|
|
236
|
-
plugins.push(new UniTips())
|
|
237
|
-
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (process.env.UNI_PLATFORM === 'mp-weixin' && process.env.NODE_ENV === 'production') {
|
|
237
|
+
plugins.push(new UniTips())
|
|
238
|
+
}
|
|
238
239
|
|
|
239
240
|
return {
|
|
240
241
|
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/vue-cli-plugin-uni",
|
|
3
|
-
"version": "2.0.2-alpha-
|
|
3
|
+
"version": "2.0.2-alpha-3061520221222001",
|
|
4
4
|
"description": "uni-app plugin for vue-cli 3",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "fxy060608",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dcloudio/uni-stat": "^2.0.2-alpha-
|
|
20
|
+
"@dcloudio/uni-stat": "^2.0.2-alpha-3061520221222001",
|
|
21
21
|
"buffer-json": "^2.0.0",
|
|
22
22
|
"clone-deep": "^4.0.1",
|
|
23
23
|
"cross-env": "^5.2.0",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"copy-webpack-plugin": ">=5",
|
|
42
42
|
"postcss": ">=7"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "dcc8aea3aeeef17980166d128ca3788a758670e1"
|
|
45
45
|
}
|