@@ -27,6 +27,7 @@ import { resolveEntries } from '../utils'
2727import getDevtool from './get-devtool'
2828import {
2929 getConfigPath ,
30+ getNewTemplateConfigPath ,
3031 cleanup ,
3132 checkBuiltinModules ,
3233 setAdaptForV8Version ,
@@ -64,6 +65,7 @@ const SPLIT_CHUNKS_SUPPORT_VERSION_FROM = 1080
6465 * @param {boolean } [launchOptions.optimizeStyleAppLevel=false] - 优化 app 样式等级
6566 * @param {boolean } [launchOptions.optimizeStylePageLevel=false] - 优化 app 样式等级
6667 * @param {boolean } [launchOptions.splitChunksMode=undefined] - 抽取公共JS
68+ * @param {boolean } [launchOptions.isUpdateDefine=undefined] - 执行compile是否更新webpack注入的变量,ide新建模板卡片会传入
6769 * @param {Object } [options.compileOptions] - 编译参数,由IDE传入
6870 * @param {production|development } mode - webpack mode
6971 * @returns {WebpackConfiguration }
@@ -76,7 +78,9 @@ export default async function genWebpackConf(launchOptions, mode) {
7678 globalConfig . projectPath = path . resolve ( globalConfig . projectPath )
7779 const cwd = globalConfig . projectPath
7880
79- const hapConfigPath = getConfigPath ( cwd )
81+ const hapConfigPath = launchOptions . isUpdateDefine
82+ ? getNewTemplateConfigPath ( cwd )
83+ : getConfigPath ( cwd )
8084 // 用于接受quickapp.config.js 或者 hap.config.js中的配置
8185 let quickappConfig
8286 // 接受命令行
@@ -92,6 +96,10 @@ export default async function genWebpackConf(launchOptions, mode) {
9296 colorconsole . error ( `加载webpack配置文件[${ hapConfigPath } ]出错:${ err . message } ` )
9397 }
9498 }
99+ // 获取到更新后的用户配置文件后要删除复制配置文件
100+ if ( launchOptions . isUpdateDefine ) {
101+ fs . unlinkSync ( hapConfigPath )
102+ }
95103 // 接收ide命令行
96104 if ( launchOptions . ideConfig && typeof launchOptions . ideConfig . cli === 'object' ) {
97105 launchOptions = Object . assign ( { } , launchOptions . ideConfig . cli , launchOptions )
0 commit comments