You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

33 lines
1.2 KiB

import { defineConfig, loadEnv } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import path from 'path';
import { updateJsonFileField } from './tools/json-editor.js';
// https://vitejs.dev/config/
/**
* @param {String} mode development/production
*/
export default defineConfig(({ mode = 'development' }) =>{
const env = loadEnv(mode, './envs');
console.log('current mode:', mode);
const manifestPath = path.resolve(__dirname, 'src/manifest.json');
updateJsonFileField(manifestPath, ['mp-toutiao', 'appid'], env.VITE_TOUTIAO_APPID);
return {
plugins: [
uni(),
],
define: {
// 抖音小程序不支持该参数 __VUE_OPTIONS_API__
// 会导致 [TMA] TypeError: this.$vm.$callCreatedHook is not a function
// "__VUE_OPTIONS_API__": false,
__API__: JSON.stringify(env.VITE_API_BASE),
},
// 修复控制台出现 Deprecation Warning: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0 的问题
css: {
preprocessorOptions: {
scss: {
silenceDeprecations: ['legacy-js-api']
}
}
}
}
})