@dcloudio/vue-cli-plugin-uni 2.0.1-35320220729002 → 2.0.1-36220220914001
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/commands/build.js +7 -3
- package/commands/serve.js +95 -41
- package/lib/app-plus/index.js +10 -3
- package/lib/chain-webpack.js +59 -24
- package/lib/configure-webpack.js +59 -17
- package/lib/copy-webpack-options.js +20 -18
- package/lib/env.js +5 -3
- package/lib/error-reporting.js +3 -4
- package/lib/h5/cssnano-options.js +13 -4
- package/lib/h5/index.js +6 -2
- package/lib/mp/index.js +47 -20
- package/lib/mp/tips.js +67 -0
- package/lib/options.js +20 -17
- package/lib/util.js +5 -1
- package/package.json +7 -5
- package/packages/app-vue-style-loader/index.js +3 -0
- package/packages/h5-vue-style-loader/index.js +3 -0
- package/packages/mp-vue/dist/mp.runtime.esm.js +8 -4
- package/packages/postcss/index.js +17 -2
- package/packages/postcss/index.v3.js +45 -30
- package/packages/uni-cloud/dist/index.js +1 -1
- package/packages/uni-push/dist/uni-push.es.js +42 -12
- package/packages/uni-push/dist/uni-push.plus.es.js +38 -30
- package/packages/vue-loader/lib/index.js +10 -11
- package/packages/vue-loader/lib/plugin-webpack5.js +34 -4
package/commands/build.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
+
const webpack = require('webpack')
|
|
2
3
|
|
|
3
4
|
const {
|
|
4
5
|
runByHBuilderX,
|
|
@@ -98,14 +99,18 @@ function getWebpackConfig (api, args, options) {
|
|
|
98
99
|
if (args.minimize && process.env.NODE_ENV !== 'production') {
|
|
99
100
|
modifyConfig(webpackConfig, config => {
|
|
100
101
|
config.optimization.minimize = true
|
|
101
|
-
|
|
102
|
+
if (webpack.version[0] <= 4) {
|
|
103
|
+
config.optimization.namedModules = false
|
|
104
|
+
}
|
|
102
105
|
})
|
|
103
106
|
} else {
|
|
104
107
|
modifyConfig(webpackConfig, config => {
|
|
105
108
|
if (!config.optimization) {
|
|
106
109
|
config.optimization = {}
|
|
107
110
|
}
|
|
108
|
-
|
|
111
|
+
if (webpack.version[0] <= 4) {
|
|
112
|
+
config.optimization.namedModules = false
|
|
113
|
+
}
|
|
109
114
|
})
|
|
110
115
|
}
|
|
111
116
|
return webpackConfig
|
|
@@ -131,7 +136,6 @@ function getWebpackConfigs (api, args, options) {
|
|
|
131
136
|
async function build (args, api, options) {
|
|
132
137
|
const fs = require('fs-extra')
|
|
133
138
|
const chalk = require('chalk')
|
|
134
|
-
const webpack = require('webpack')
|
|
135
139
|
|
|
136
140
|
const {
|
|
137
141
|
log,
|
package/commands/serve.js
CHANGED
|
@@ -37,7 +37,7 @@ module.exports = (api, options) => {
|
|
|
37
37
|
|
|
38
38
|
const url = require('url')
|
|
39
39
|
const path = require('path')
|
|
40
|
-
const chalk = require('
|
|
40
|
+
const { chalk } = require('@vue/cli-shared-utils')
|
|
41
41
|
const webpack = require('webpack')
|
|
42
42
|
const WebpackDevServer = require('webpack-dev-server')
|
|
43
43
|
const portfinder = require('portfinder')
|
|
@@ -139,48 +139,98 @@ module.exports = (api, options) => {
|
|
|
139
139
|
const compiler = webpack(webpackConfig)
|
|
140
140
|
|
|
141
141
|
// create server
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
142
|
+
let server
|
|
143
|
+
if (webpack.version[0] > 4) {
|
|
144
|
+
server = new WebpackDevServer(Object.assign({
|
|
145
|
+
historyApiFallback: {
|
|
146
|
+
disableDotRule: true,
|
|
147
|
+
rewrites: [{
|
|
148
|
+
from: /./,
|
|
149
|
+
to: path.posix.join(options.publicPath, 'index.html')
|
|
150
|
+
}]
|
|
151
|
+
},
|
|
152
|
+
hot: !isProduction,
|
|
153
|
+
compress: isProduction,
|
|
154
|
+
static: {
|
|
155
|
+
directory: api.resolve('public'),
|
|
156
|
+
publicPath: options.publicPath,
|
|
157
|
+
watch: !isProduction,
|
|
158
|
+
...projectDevServerOptions.static
|
|
159
|
+
},
|
|
160
|
+
client: {
|
|
161
|
+
logging: 'none',
|
|
162
|
+
overlay: isProduction // TODO disable this
|
|
163
|
+
? false
|
|
164
|
+
: { warnings: false, errors: true },
|
|
165
|
+
progress: !process.env.VUE_CLI_TEST,
|
|
166
|
+
...projectDevServerOptions.client
|
|
161
167
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
168
|
+
}, projectDevServerOptions, {
|
|
169
|
+
https: useHttps,
|
|
170
|
+
proxy: proxySettings,
|
|
171
|
+
setupMiddlewares (middlewares, devServer) {
|
|
172
|
+
// launch editor support.
|
|
173
|
+
// this works with vue-devtools & @vue/cli-overlay
|
|
174
|
+
devServer.app.use('/__open-in-editor', launchEditorMiddleware(() => console.log(
|
|
175
|
+
'To specify an editor, specify the EDITOR env variable or ' +
|
|
176
|
+
'add "editor" field to your Vue project config.\n'
|
|
177
|
+
)))
|
|
178
|
+
|
|
179
|
+
// allow other plugins to register middlewares, e.g. PWA
|
|
180
|
+
// todo: migrate to the new API interface
|
|
181
|
+
api.service.devServerConfigFns.forEach(fn => fn(devServer.app, devServer))
|
|
182
|
+
|
|
183
|
+
if (projectDevServerOptions.setupMiddlewares) {
|
|
184
|
+
return projectDevServerOptions.setupMiddlewares(middlewares, devServer)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return middlewares
|
|
188
|
+
}
|
|
189
|
+
}), compiler)
|
|
190
|
+
} else {
|
|
191
|
+
server = new WebpackDevServer(compiler, Object.assign({
|
|
192
|
+
clientLogLevel: 'none',
|
|
193
|
+
historyApiFallback: {
|
|
194
|
+
disableDotRule: true,
|
|
195
|
+
rewrites: [{
|
|
196
|
+
from: /./,
|
|
197
|
+
to: path.posix.join(options.publicPath, 'index.html')
|
|
198
|
+
}]
|
|
199
|
+
},
|
|
200
|
+
contentBase: api.resolve('public'),
|
|
201
|
+
watchContentBase: !isProduction,
|
|
202
|
+
hot: !isProduction,
|
|
203
|
+
quiet: true,
|
|
204
|
+
compress: isProduction,
|
|
205
|
+
publicPath: options.publicPath,
|
|
206
|
+
overlay: isProduction // TODO disable this
|
|
207
|
+
? false : {
|
|
208
|
+
warnings: false,
|
|
209
|
+
errors: true
|
|
210
|
+
}
|
|
211
|
+
}, projectDevServerOptions, {
|
|
212
|
+
https: useHttps,
|
|
213
|
+
proxy: proxySettings,
|
|
214
|
+
before (app, server) {
|
|
166
215
|
// launch editor support.
|
|
167
216
|
// this works with vue-devtools & @vue/cli-overlay
|
|
168
|
-
|
|
169
|
-
|
|
217
|
+
app.use('/__open-in-editor', launchEditorMiddleware(() => console.log(
|
|
218
|
+
'To specify an editor, sepcify the EDITOR env variable or ' +
|
|
170
219
|
'add "editor" field to your Vue project config.\n'
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
220
|
+
)))
|
|
221
|
+
// allow other plugins to register middlewares, e.g. PWA
|
|
222
|
+
api.service.devServerConfigFns.forEach(fn => fn(app, server))
|
|
223
|
+
// apply in project middlewares
|
|
224
|
+
projectDevServerOptions.before && projectDevServerOptions.before(app,
|
|
225
|
+
server)
|
|
226
|
+
}
|
|
227
|
+
}))
|
|
228
|
+
}
|
|
179
229
|
|
|
180
230
|
;
|
|
181
231
|
['SIGINT', 'SIGTERM'].forEach(signal => {
|
|
182
232
|
process.on(signal, () => {
|
|
183
|
-
server.close(() => {
|
|
233
|
+
server[webpack.version[0] > 4 ? 'stopCallback' : 'close'](() => {
|
|
184
234
|
process.exit(0)
|
|
185
235
|
})
|
|
186
236
|
})
|
|
@@ -192,7 +242,7 @@ module.exports = (api, options) => {
|
|
|
192
242
|
process.stdin.on('data', data => {
|
|
193
243
|
if (data.toString() === 'close') {
|
|
194
244
|
console.log('got close signal!')
|
|
195
|
-
server.close(() => {
|
|
245
|
+
server[webpack.version[0] > 4 ? 'stopCallback' : 'close'](() => {
|
|
196
246
|
process.exit(0)
|
|
197
247
|
})
|
|
198
248
|
}
|
|
@@ -303,11 +353,15 @@ module.exports = (api, options) => {
|
|
|
303
353
|
server.showStatus = function () {}
|
|
304
354
|
}
|
|
305
355
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
356
|
+
if (webpack.version[0] > 4) {
|
|
357
|
+
server.start().catch(err => reject(err))
|
|
358
|
+
} else {
|
|
359
|
+
server.listen(port, host, err => {
|
|
360
|
+
if (err) {
|
|
361
|
+
reject(err)
|
|
362
|
+
}
|
|
363
|
+
})
|
|
364
|
+
}
|
|
311
365
|
})
|
|
312
366
|
})
|
|
313
367
|
}
|
package/lib/app-plus/index.js
CHANGED
|
@@ -70,7 +70,11 @@ const v3 = {
|
|
|
70
70
|
webpackConfig.optimization = {}
|
|
71
71
|
}
|
|
72
72
|
// disable noEmitOnErrors
|
|
73
|
-
|
|
73
|
+
if (webpack.version[0] > 4) {
|
|
74
|
+
webpackConfig.optimization.emitOnErrors = true
|
|
75
|
+
} else {
|
|
76
|
+
webpackConfig.optimization.noEmitOnErrors = false
|
|
77
|
+
}
|
|
74
78
|
|
|
75
79
|
if (isAppService) {
|
|
76
80
|
webpackConfig.optimization.runtimeChunk = {
|
|
@@ -134,7 +138,8 @@ const v3 = {
|
|
|
134
138
|
output: {
|
|
135
139
|
filename: '[name].js',
|
|
136
140
|
chunkFilename: '[id].js',
|
|
137
|
-
|
|
141
|
+
// webpack5 use strict
|
|
142
|
+
globalObject: webpack.version[0] > 4 ? '(new Function("return this")())' : 'this'
|
|
138
143
|
},
|
|
139
144
|
performance: {
|
|
140
145
|
hints: false
|
|
@@ -158,7 +163,7 @@ const v3 = {
|
|
|
158
163
|
compiler: vueLoader.compiler,
|
|
159
164
|
before: [
|
|
160
165
|
beforeCode + require('../util').getAutomatorCode() + statCode + pushCode + uniCloudCode +
|
|
161
|
-
|
|
166
|
+
getGlobalUsingComponentsCode()
|
|
162
167
|
]
|
|
163
168
|
}
|
|
164
169
|
}]
|
|
@@ -260,6 +265,8 @@ const v3 = {
|
|
|
260
265
|
})
|
|
261
266
|
}
|
|
262
267
|
|
|
268
|
+
webpackConfig.plugin('vue-loader').use(require(vueLoader.loader).VueLoaderPlugin)
|
|
269
|
+
|
|
263
270
|
webpackConfig.plugins.delete('hmr')
|
|
264
271
|
webpackConfig.plugins.delete('html')
|
|
265
272
|
webpackConfig.plugins.delete('copy')
|
package/lib/chain-webpack.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
sassLoaderVersion
|
|
5
|
-
} = require('@dcloudio/uni-cli-shared/lib/scss')
|
|
2
|
+
const webpack = require('webpack')
|
|
6
3
|
|
|
7
4
|
const {
|
|
8
5
|
getPartialIdentifier
|
|
@@ -23,11 +20,38 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
|
|
|
23
20
|
const urlLoader = require('@dcloudio/uni-cli-shared/lib/url-loader')
|
|
24
21
|
const staticTypes = ['images', 'media', 'fonts']
|
|
25
22
|
staticTypes.forEach(staticType => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
const newOptions = urlLoader.options()
|
|
24
|
+
if (webpack.version[0] > 4) {
|
|
25
|
+
if ('limit' in newOptions) {
|
|
26
|
+
webpackConfig.module.rule(staticType).parser({
|
|
27
|
+
dataUrlCondition: {
|
|
28
|
+
maxSize: newOptions.limit
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
if (newOptions.fallback && newOptions.fallback.options) {
|
|
33
|
+
const generator = {}
|
|
34
|
+
const oldOptions = newOptions.fallback.options
|
|
35
|
+
const keys = ['publicPath', 'outputPath']
|
|
36
|
+
keys.forEach(key => {
|
|
37
|
+
generator[key] = pathData => {
|
|
38
|
+
const outputPath = oldOptions.outputPath(null, pathData.module.request)
|
|
39
|
+
const basename = path.basename(outputPath)
|
|
40
|
+
return outputPath.substring(0, outputPath.length - basename.length)
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
generator.filename = pathData => {
|
|
44
|
+
return path.basename(pathData.module.request)
|
|
45
|
+
}
|
|
46
|
+
webpackConfig.module.rule(staticType).set('generator', generator)
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
webpackConfig.module
|
|
50
|
+
.rule(staticType)
|
|
51
|
+
.use('url-loader')
|
|
52
|
+
.loader(urlLoader.loader)
|
|
53
|
+
.tap(options => Object.assign(options, newOptions))
|
|
54
|
+
}
|
|
31
55
|
})
|
|
32
56
|
// 条件编译 vue 文件统一直接过滤html,js,css三种类型,单独资源文件引用各自过滤
|
|
33
57
|
|
|
@@ -56,6 +80,18 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
|
|
|
56
80
|
))
|
|
57
81
|
.before('css-loader')
|
|
58
82
|
}
|
|
83
|
+
if (webpack.version[0] > 4) {
|
|
84
|
+
langRule.oneOf(type)
|
|
85
|
+
.use('css-loader')
|
|
86
|
+
.tap(options => {
|
|
87
|
+
options.url = {
|
|
88
|
+
filter: function (url) {
|
|
89
|
+
return url[0] !== '/'
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return options
|
|
93
|
+
})
|
|
94
|
+
}
|
|
59
95
|
langRule.oneOf(type)
|
|
60
96
|
.use('uniapp-preprocss')
|
|
61
97
|
.loader(resolve('packages/webpack-preprocess-loader'))
|
|
@@ -72,21 +108,19 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
|
|
|
72
108
|
})
|
|
73
109
|
})
|
|
74
110
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (options.
|
|
80
|
-
|
|
81
|
-
options.sassOptions = {}
|
|
82
|
-
}
|
|
83
|
-
options.sassOptions.indentedSyntax = true
|
|
84
|
-
delete options.indentedSyntax
|
|
111
|
+
// vue cli 3 and sass-loader 8
|
|
112
|
+
cssTypes.forEach(type => {
|
|
113
|
+
webpackConfig.module.rule('sass').oneOf(type).use('sass-loader').tap(options => {
|
|
114
|
+
if (options.indentedSyntax) {
|
|
115
|
+
if (!options.sassOptions) {
|
|
116
|
+
options.sassOptions = {}
|
|
85
117
|
}
|
|
86
|
-
|
|
87
|
-
|
|
118
|
+
options.sassOptions.indentedSyntax = true
|
|
119
|
+
delete options.indentedSyntax
|
|
120
|
+
}
|
|
121
|
+
return options
|
|
88
122
|
})
|
|
89
|
-
}
|
|
123
|
+
})
|
|
90
124
|
|
|
91
125
|
platformOptions.chainWebpack(webpackConfig, vueOptions, api)
|
|
92
126
|
// define
|
|
@@ -104,8 +138,9 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
|
|
|
104
138
|
'process.env.UNICLOUD_DEBUG': process.env.UNICLOUD_DEBUG,
|
|
105
139
|
'process.env.RUN_BY_HBUILDERX': process.env.RUN_BY_HBUILDERX,
|
|
106
140
|
'process.env.UNI_AUTOMATOR_WS_ENDPOINT': JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT),
|
|
107
|
-
'process.env.
|
|
108
|
-
'process.env.
|
|
141
|
+
'process.env.UNI_STATISTICS_CONFIG': process.env.UNI_STATISTICS_CONFIG,
|
|
142
|
+
'process.env.UNI_STAT_UNI_CLOUD': process.env.UNI_STAT_UNI_CLOUD,
|
|
143
|
+
'process.env.UNI_STAT_DEBUG': process.env.UNI_STAT_DEBUG,
|
|
109
144
|
'process.env.UNI_COMPILER_VERSION': JSON.stringify(process.env.UNI_COMPILER_VERSION),
|
|
110
145
|
'process.env.UNI_APP_VERSION_NAME': JSON.stringify(process.env.UNI_APP_VERSION_NAME),
|
|
111
146
|
'process.env.UNI_APP_VERSION_CODE': JSON.stringify(process.env.UNI_APP_VERSION_CODE)
|
package/lib/configure-webpack.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
const webpack = require('webpack')
|
|
4
|
-
const RuleSet = require('webpack/lib/RuleSet')
|
|
5
4
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
5
|
+
const CopyWebpackPluginVersion = Number(require('copy-webpack-plugin/package.json').version.split('.')[0])
|
|
6
6
|
|
|
7
7
|
const merge = require('webpack-merge')
|
|
8
8
|
|
|
@@ -39,12 +39,44 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
39
39
|
return (rule, i) => {
|
|
40
40
|
const clone = Object.assign({}, rule)
|
|
41
41
|
delete clone.include
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
if (webpack.version[0] > 4) {
|
|
43
|
+
const BasicEffectRulePlugin = require('webpack/lib/rules/BasicEffectRulePlugin')
|
|
44
|
+
const BasicMatcherRulePlugin = require('webpack/lib/rules/BasicMatcherRulePlugin')
|
|
45
|
+
const RuleSetCompiler = require('webpack/lib/rules/RuleSetCompiler')
|
|
46
|
+
const UseEffectRulePlugin = require('webpack/lib/rules/UseEffectRulePlugin')
|
|
47
|
+
const ruleSetCompiler = new RuleSetCompiler([
|
|
48
|
+
new BasicMatcherRulePlugin('test', 'resource'),
|
|
49
|
+
new BasicMatcherRulePlugin('include', 'resource'),
|
|
50
|
+
new BasicMatcherRulePlugin('exclude', 'resource', true),
|
|
51
|
+
new BasicMatcherRulePlugin('resource'),
|
|
52
|
+
new BasicMatcherRulePlugin('conditions'),
|
|
53
|
+
new BasicMatcherRulePlugin('resourceQuery'),
|
|
54
|
+
new BasicMatcherRulePlugin('realResource'),
|
|
55
|
+
new BasicMatcherRulePlugin('issuer'),
|
|
56
|
+
new BasicMatcherRulePlugin('compiler'),
|
|
57
|
+
new BasicEffectRulePlugin('type'),
|
|
58
|
+
new BasicEffectRulePlugin('sideEffects'),
|
|
59
|
+
new BasicEffectRulePlugin('parser'),
|
|
60
|
+
new BasicEffectRulePlugin('resolve'),
|
|
61
|
+
new BasicEffectRulePlugin('generator'),
|
|
62
|
+
new UseEffectRulePlugin()
|
|
63
|
+
])
|
|
64
|
+
const ruleSet = ruleSetCompiler.compile([{
|
|
65
|
+
rules: [clone]
|
|
66
|
+
}])
|
|
67
|
+
const rules = ruleSet.exec({
|
|
68
|
+
resource: fakeFile
|
|
69
|
+
})
|
|
70
|
+
return rules.length > 0 && rule.use
|
|
71
|
+
} else {
|
|
72
|
+
const RuleSet = require('webpack/lib/RuleSet')
|
|
73
|
+
const normalized = RuleSet.normalizeRule(clone, {}, '')
|
|
74
|
+
return (
|
|
75
|
+
!rule.enforce &&
|
|
45
76
|
normalized.resource &&
|
|
46
77
|
normalized.resource(fakeFile)
|
|
47
|
-
|
|
78
|
+
)
|
|
79
|
+
}
|
|
48
80
|
}
|
|
49
81
|
}
|
|
50
82
|
|
|
@@ -150,15 +182,23 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
150
182
|
for (let i = rawRules.length - 1; i >= 0; i--) {
|
|
151
183
|
const uses = rawRules[i].use
|
|
152
184
|
if (Array.isArray(uses)) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
185
|
+
const babelLoader = uses.find(use => babelLoaderRe.test(use.loader))
|
|
186
|
+
if (babelLoader) {
|
|
187
|
+
const options = api.genCacheConfig('babel-loader/' + process.env.UNI_PLATFORM, getPartialIdentifier())
|
|
188
|
+
if (webpack.version[0] > 4) {
|
|
189
|
+
babelLoader.options = babelLoader.options || {}
|
|
190
|
+
Object.assign(babelLoader.options, process.env.UNI_USING_CACHE ? options : {
|
|
191
|
+
cacheDirectory: false
|
|
192
|
+
})
|
|
160
193
|
} else {
|
|
161
|
-
uses.
|
|
194
|
+
const index = uses.findIndex(use => cacheLoaderRe.test(use.loader))
|
|
195
|
+
if (index >= 0) {
|
|
196
|
+
if (process.env.UNI_USING_CACHE) {
|
|
197
|
+
Object.assign(uses[index].options, options)
|
|
198
|
+
} else {
|
|
199
|
+
uses.splice(index, 1)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
162
202
|
}
|
|
163
203
|
}
|
|
164
204
|
}
|
|
@@ -198,12 +238,13 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
198
238
|
vueOptions.pluginOptions['uni-app-plus'].view
|
|
199
239
|
|
|
200
240
|
if (!isAppView) { // app-plus view不需要copy
|
|
201
|
-
|
|
241
|
+
const patterns = getCopyWebpackPluginOptions(manifestPlatformOptions, vueOptions)
|
|
242
|
+
plugins.push(new CopyWebpackPlugin(CopyWebpackPluginVersion > 5 ? { patterns } : patterns))
|
|
202
243
|
}
|
|
203
244
|
if (!process.env.UNI_SUBPACKGE || !process.env.UNI_MP_PLUGIN) {
|
|
204
245
|
try {
|
|
205
246
|
const automatorJson = require.resolve('@dcloudio/uni-automator/dist/automator.json')
|
|
206
|
-
|
|
247
|
+
const patterns = [{
|
|
207
248
|
from: automatorJson,
|
|
208
249
|
to: '../.automator/' + (process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM) +
|
|
209
250
|
'/.automator.json',
|
|
@@ -216,8 +257,9 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
216
257
|
}
|
|
217
258
|
return ''
|
|
218
259
|
}
|
|
219
|
-
}]
|
|
220
|
-
|
|
260
|
+
}]
|
|
261
|
+
plugins.push(new CopyWebpackPlugin(CopyWebpackPluginVersion > 5 ? { patterns } : patterns))
|
|
262
|
+
} catch (e) { }
|
|
221
263
|
}
|
|
222
264
|
|
|
223
265
|
if (process.UNI_SCRIPT_ENV && Object.keys(process.UNI_SCRIPT_ENV).length) {
|
|
@@ -7,6 +7,7 @@ const {
|
|
|
7
7
|
initI18nOptions
|
|
8
8
|
} = require('@dcloudio/uni-cli-shared/lib/i18n')
|
|
9
9
|
const assetsDir = 'static'
|
|
10
|
+
const CopyWebpackPluginVersion = Number(require('copy-webpack-plugin/package.json').version.split('.')[0])
|
|
10
11
|
|
|
11
12
|
function getAssetsCopyOption (from, options = {}) {
|
|
12
13
|
if (path.isAbsolute(from)) {
|
|
@@ -42,7 +43,9 @@ function getAssetsCopyOptions (assetsDir) {
|
|
|
42
43
|
|
|
43
44
|
const copyOptions = []
|
|
44
45
|
// 主包静态资源
|
|
45
|
-
const mainAssetsCopyOption = getAssetsCopyOption(assetsDir, {
|
|
46
|
+
const mainAssetsCopyOption = getAssetsCopyOption(assetsDir, CopyWebpackPluginVersion > 5 ? {
|
|
47
|
+
globOptions: { ignore }
|
|
48
|
+
} : {
|
|
46
49
|
ignore
|
|
47
50
|
})
|
|
48
51
|
if (mainAssetsCopyOption) {
|
|
@@ -51,11 +54,11 @@ function getAssetsCopyOptions (assetsDir) {
|
|
|
51
54
|
// 分包静态资源
|
|
52
55
|
process.UNI_SUBPACKAGES &&
|
|
53
56
|
Object.keys(process.UNI_SUBPACKAGES).forEach(root => {
|
|
54
|
-
const subAssetsCopyOption = getAssetsCopyOption(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
)
|
|
57
|
+
const subAssetsCopyOption = getAssetsCopyOption(path.join(root, assetsDir), CopyWebpackPluginVersion > 5 ? {
|
|
58
|
+
globOptions: { ignore }
|
|
59
|
+
} : {
|
|
60
|
+
ignore
|
|
61
|
+
})
|
|
59
62
|
if (subAssetsCopyOption) {
|
|
60
63
|
copyOptions.push(subAssetsCopyOption)
|
|
61
64
|
}
|
|
@@ -89,14 +92,14 @@ function getCopyWebpackPluginOptions (platformOptions, vueOptions) {
|
|
|
89
92
|
})
|
|
90
93
|
// 自动化测试时,不启用androidPrivacy.json
|
|
91
94
|
if (process.env.UNI_PLATFORM === 'app-plus' && !process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
const fileName = 'androidPrivacy.json'
|
|
96
|
+
const context = path.resolve(process.env.UNI_INPUT_DIR)
|
|
97
|
+
if (fs.existsSync(path.join(context, fileName))) {
|
|
98
|
+
copyOptions.push({
|
|
99
|
+
from: fileName,
|
|
100
|
+
context,
|
|
101
|
+
to: fileName,
|
|
102
|
+
transform (content) {
|
|
100
103
|
const options = initI18nOptions(
|
|
101
104
|
process.env.UNI_PLATFORM,
|
|
102
105
|
process.env.UNI_INPUT_DIR,
|
|
@@ -108,9 +111,8 @@ function getCopyWebpackPluginOptions (platformOptions, vueOptions) {
|
|
|
108
111
|
}
|
|
109
112
|
return compileI18nJsonStr(content.toString(), options)
|
|
110
113
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
})
|
|
114
|
+
})
|
|
115
|
+
}
|
|
114
116
|
}
|
|
115
117
|
return copyOptions
|
|
116
118
|
}
|
|
@@ -118,4 +120,4 @@ function getCopyWebpackPluginOptions (platformOptions, vueOptions) {
|
|
|
118
120
|
module.exports = {
|
|
119
121
|
assetsDir,
|
|
120
122
|
getCopyWebpackPluginOptions
|
|
121
|
-
}
|
|
123
|
+
}
|
package/lib/env.js
CHANGED
|
@@ -324,8 +324,9 @@ if ((process.env.UNI_PLATFORM === 'mp-kuaishou' || process.env.UNI_PLATFORM ===
|
|
|
324
324
|
|
|
325
325
|
process.env.MERGE_VIRTUAL_HOST_ATTRIBUTES = (!!platformOptions.mergeVirtualHostAttributes).toString()
|
|
326
326
|
|
|
327
|
-
process.env.
|
|
328
|
-
process.env.
|
|
327
|
+
process.env.UNI_STATISTICS_CONFIG = '""'
|
|
328
|
+
process.env.UNI_STAT_UNI_CLOUD = '""'
|
|
329
|
+
process.env.UNI_STAT_DEBUG = '""'
|
|
329
330
|
if (
|
|
330
331
|
process.env.UNI_USING_COMPONENTS ||
|
|
331
332
|
process.env.UNI_PLATFORM === 'h5'
|
|
@@ -336,9 +337,10 @@ if (
|
|
|
336
337
|
)
|
|
337
338
|
|
|
338
339
|
if (uniStatistics.enable === true) {
|
|
339
|
-
process.env.UNI_USING_STAT = uniStatistics.version ===
|
|
340
|
+
process.env.UNI_USING_STAT = Number(uniStatistics.version) === 2 ? '2' : '1'
|
|
340
341
|
// 获取服务空间配置信息
|
|
341
342
|
const uniCloudConfig = uniStatistics.uniCloud || {}
|
|
343
|
+
process.env.UNI_STATISTICS_CONFIG = JSON.stringify(uniStatistics)
|
|
342
344
|
process.env.UNI_STAT_UNI_CLOUD = JSON.stringify(uniCloudConfig)
|
|
343
345
|
process.env.UNI_STAT_DEBUG = uniStatistics.debug === true ? 'true' : 'false'
|
|
344
346
|
|
package/lib/error-reporting.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const {
|
|
2
|
-
|
|
2
|
+
pathToRegexp,
|
|
3
3
|
isInHBuilderX
|
|
4
4
|
} = require('@dcloudio/uni-cli-shared/lib/util')
|
|
5
5
|
const plp = require('@dcloudio/webpack-uni-pages-loader/package.json')
|
|
@@ -18,8 +18,8 @@ class ErrorReport {
|
|
|
18
18
|
this._https = null
|
|
19
19
|
this._crypto = null
|
|
20
20
|
this._cacheList = []
|
|
21
|
-
this._UNI_INPUT_DIR_REG =
|
|
22
|
-
this._UNI_CLI_CONTEXT_REG =
|
|
21
|
+
this._UNI_INPUT_DIR_REG = pathToRegexp(process.env.UNI_INPUT_DIR, { global: true })
|
|
22
|
+
this._UNI_CLI_CONTEXT_REG = pathToRegexp(process.env.UNI_CLI_CONTEXT, { global: true })
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
get os () {
|
|
@@ -47,7 +47,6 @@ class ErrorReport {
|
|
|
47
47
|
} catch (e) {}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
err = normalizePath(err) || ''
|
|
51
50
|
err = err.replace(this._UNI_INPUT_DIR_REG, 'UNI_INPUT_DIR')
|
|
52
51
|
err = err.replace(this._UNI_CLI_CONTEXT_REG, 'UNI_CLI_CONTEXT')
|
|
53
52
|
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
const {
|
|
2
2
|
getPlatformCssnano
|
|
3
3
|
} = require('@dcloudio/uni-cli-shared')
|
|
4
|
+
const webpack = require('webpack')
|
|
4
5
|
|
|
5
6
|
module.exports = function initCssnanoOptions (webpackConfig) {
|
|
6
7
|
const module = webpackConfig.module
|
|
7
8
|
// TODO 临时 hack calc:false 看看 vue cli 后续是否开放 cssnano 的配置
|
|
8
9
|
const cssnanoOptions = {
|
|
9
|
-
sourceMap: false
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
sourceMap: false
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const plugins = [require('cssnano')({
|
|
14
|
+
preset: ['default', getPlatformCssnano()]
|
|
15
|
+
})]
|
|
16
|
+
|
|
17
|
+
// TODO postcss-loader version > 4
|
|
18
|
+
if (webpack.version[0] > 4) {
|
|
19
|
+
cssnanoOptions.postcssOptions = { plugins }
|
|
20
|
+
} else {
|
|
21
|
+
cssnanoOptions.plugins = plugins
|
|
13
22
|
}
|
|
14
23
|
|
|
15
24
|
module.rule('css').oneOf('vue-modules').use('cssnano').loader('postcss-loader').options(cssnanoOptions)
|
package/lib/h5/index.js
CHANGED
|
@@ -160,9 +160,13 @@ module.exports = {
|
|
|
160
160
|
},
|
|
161
161
|
plugins,
|
|
162
162
|
optimization: {
|
|
163
|
-
moduleIds: 'hashed'
|
|
163
|
+
moduleIds: webpack.version[0] > 4 ? 'deterministic' : 'hashed'
|
|
164
164
|
},
|
|
165
|
-
devServer: {
|
|
165
|
+
devServer: webpack.version[0] > 4 ? {
|
|
166
|
+
watchFiles: {
|
|
167
|
+
options: require('../util').getWatchOptions()
|
|
168
|
+
}
|
|
169
|
+
} : {
|
|
166
170
|
watchOptions: require('../util').getWatchOptions()
|
|
167
171
|
}
|
|
168
172
|
}
|