|
@ -2,6 +2,7 @@ import { defineConfig, loadEnv } from 'vite'; |
|
|
import uni from '@dcloudio/vite-plugin-uni'; |
|
|
import uni from '@dcloudio/vite-plugin-uni'; |
|
|
import path from 'path'; |
|
|
import path from 'path'; |
|
|
import { updateJsonFileField } from './tools/json-editor.js'; |
|
|
import { updateJsonFileField } from './tools/json-editor.js'; |
|
|
|
|
|
import { generatePackageJsonPlugin } from './tools/generate-package-plugin.js'; |
|
|
// https://vitejs.dev/config/
|
|
|
// https://vitejs.dev/config/
|
|
|
/** |
|
|
/** |
|
|
* @param {String} mode development/production |
|
|
* @param {String} mode development/production |
|
@ -9,12 +10,16 @@ import { updateJsonFileField } from './tools/json-editor.js'; |
|
|
export default defineConfig(({ mode = 'development' }) =>{ |
|
|
export default defineConfig(({ mode = 'development' }) =>{ |
|
|
const env = loadEnv(mode, './envs'); |
|
|
const env = loadEnv(mode, './envs'); |
|
|
console.log('current mode:', mode); |
|
|
console.log('current mode:', mode); |
|
|
const manifestPath = path.resolve(__dirname, 'src/manifest.json'); |
|
|
|
|
|
updateJsonFileField(manifestPath, ['mp-toutiao', 'appid'], env.VITE_TOUTIAO_APPID); |
|
|
|
|
|
|
|
|
const plugins = [ uni() ]; |
|
|
|
|
|
if (process.env.UNI_PLATFORM === 'mp-toutiao'){ |
|
|
|
|
|
// 根据配置文件配置 appid
|
|
|
|
|
|
const manifestPath = path.resolve(__dirname, 'src/manifest.json'); |
|
|
|
|
|
updateJsonFileField(manifestPath, ['mp-toutiao', 'appid'], env.VITE_TOUTIAO_APPID); |
|
|
|
|
|
// 配置行业sdk
|
|
|
|
|
|
plugins.push(generatePackageJsonPlugin(process.env.UNI_OUTPUT_DIR, { industrySDK: true })); |
|
|
|
|
|
} |
|
|
return { |
|
|
return { |
|
|
plugins: [ |
|
|
|
|
|
uni(), |
|
|
|
|
|
], |
|
|
|
|
|
|
|
|
plugins, |
|
|
define: { |
|
|
define: { |
|
|
// 抖音小程序不支持该参数 __VUE_OPTIONS_API__
|
|
|
// 抖音小程序不支持该参数 __VUE_OPTIONS_API__
|
|
|
// 会导致 [TMA] TypeError: this.$vm.$callCreatedHook is not a function
|
|
|
// 会导致 [TMA] TypeError: this.$vm.$callCreatedHook is not a function
|
|
@ -30,4 +35,4 @@ export default defineConfig(({ mode = 'development' }) =>{ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
|
|
|
|
|
|
}) |