import path from 'path';
import * as fs from 'fs';
import * as https from 'https';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import eslint from 'vite-plugin-eslint';
import { visualizer } from 'rollup-plugin-visualizer';
import * as ssl from 'ssl-root-cas';
import { commonAssetsPrefix } from './src/constants/config-env';
const { ANALYZE } = process.env;
const rootCas = ssl.create();
rootCas.addFile(path.resolve(__dirname, 'node_modules/@ffe/fcore-build-utils/.certs/cert.pem'));
https.globalAgent.options.ca = rootCas;
function getHttpsConfig() {
return {
cert: fs.readFileSync(path.resolve(__dirname, 'node_modules/@ffe/fcore-build-utils/.certs/cert.pem')),
key: fs.readFileSync(path.resolve(__dirname, 'node_modules/@ffe/fcore-build-utils/.certs/key.pem')),
};
}
export default defineConfig(config => ({
base: config.mode === 'production' ? commonAssetsPrefix : '/',
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'@aurora/theme': '@aurora/theme-saas',
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "./theme-saas/styles.scss";',
},
},
},
plugins: [
vue(),
eslint({
// 检查出“警告”级别的问题时,输出警告到控制台
emitWarning: true,
// 检查出“错误”级别的问题时,不输出为 error(不抛出 error,不影响渲染,只输出 错误信息)
emitError: false,
// 检查出 warning 时,不让打包/启动失败
failOnWarning: false,
}),
...(ANALYZE === 'true'
? [
visualizer({
open: false,
gzipSize: true,
brotliSize: true,
filename: 'dist/stats.html',
}),
]
: []),
],
build: {
target: 'esnext',
},
define: {
VERSION_PLACEHOLDER: JSON.stringify('1.0.0'),
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false,
'process.env': Object.assign({}, process.env),
},
server: {
hmr: true,
port: 4173,
open: true,
host: 'localhost.huawei.com',
cors: true,
proxy: {
'/ffe': {
target: 'https://kwesit.huawei.com',
changeOrigin: true,
rewrite: pathItem => pathItem.replace(/^\/ffe/, ''),
},
},
https: getHttpsConfig(),
},
}));
以上是我的vite设置,打包后部署完打开index。html白屏,无任何报错,帮忙看看可能是什么原因