Skip to content

Commit dbf7865

Browse files
committed
fix: curl 在 windows cmd 中不支持, 增加 definePlugin 全局变量接口
1 parent 4a7c757 commit dbf7865

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

config/argv.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var fs = require('fs')
33
var util = require('util')
44
var resolve = require('resolve')
55
var glob = require('glob')
6+
var webpack = require('webpack')
67
// const { NpmAutoInstallWebpackPlugin } = require('npm-auto-install-webpack-plugin')
78

89
function saveEntryMain(index, src, mpType) {
@@ -86,9 +87,9 @@ function mergeArgvConfig (config) {
8687
const floders = ['./src/', './mpvue-pages/']
8788
const searchFilters = ['./**/**/main.js', './**/**/app.vue', './**/**/App.vue', './**/**/index.vue']
8889
config.argvConfig = {
89-
// plugins: [
90-
// new NpmAutoInstallWebpackPlugin()
91-
// ]
90+
plugins: [
91+
// new NpmAutoInstallWebpackPlugin()
92+
]
9293
}
9394

9495
// 拼接自定义的参数
@@ -99,6 +100,7 @@ function mergeArgvConfig (config) {
99100
component: argvComponent, // true, undefined
100101
output: argvOutput, // pathString, undefined
101102
config: argvCnf, // pathString, undefined
103+
definePlugin: argvDefinePlugin, // object, undefined
102104
...resetConfig
103105
} = argv
104106
const mpType = argvComponent ? 'component' : 'page'
@@ -134,16 +136,6 @@ function mergeArgvConfig (config) {
134136
defConfig.assetsRoot = assetsRoot
135137
}
136138

137-
// 合并自定义 webpack config
138-
if (typeof argvCnf === 'string') {
139-
try {
140-
config.argvConfig = require('webpack-merge')(config.argvConfig, require(path.resolve(argvCnf)))
141-
} catch (e) { }
142-
}
143-
144-
Object.assign(config.build, resetConfig, defConfig)
145-
Object.assign(config.dev, resetConfig, defConfig)
146-
147139
const allEntry = Object.keys(defConfig.entry)
148140

149141
if (!allEntry.length) {
@@ -157,6 +149,21 @@ function mergeArgvConfig (config) {
157149
}
158150
})
159151

152+
// DefinePlugin
153+
if (argvDefinePlugin) {
154+
config.argvConfig.plugins.push(new webpack.DefinePlugin(argvDefinePlugin))
155+
}
156+
157+
// 合并自定义 webpack config
158+
if (typeof argvCnf === 'string') {
159+
try {
160+
config.argvConfig = require('webpack-merge')(config.argvConfig, require(path.resolve(argvCnf)))
161+
} catch (e) { }
162+
}
163+
164+
Object.assign(config.build, resetConfig, defConfig)
165+
Object.assign(config.dev, resetConfig, defConfig)
166+
160167
return config
161168
}
162169

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mpvue-simple",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "辅助 mpvue 快速开发 Page / Component 级小程序页面的工具",
55
"main": "index.js",
66
"bin": "bin/mpvue-simple",

0 commit comments

Comments
 (0)