sakura/vite.config.ts

82 lines
1.8 KiB
TypeScript
Raw Normal View History

2021-07-09 18:28:29 +08:00
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
2021-07-13 16:15:03 +08:00
// import legacy from '@vitejs/plugin-legacy'
2021-07-09 18:28:29 +08:00
import path from 'path'
import svgicon from 'vite-plugin-svgicon'
2021-07-29 00:01:45 +08:00
// import viteStylelint from '@amatlash/vite-plugin-stylelint'
2021-07-09 18:28:29 +08:00
const target = process.env.APP_TARGET
2021-07-09 18:28:29 +08:00
// https://vitejs.dev/config/
export default defineConfig({
base: 'http://localhost:9000/',
resolve: {
alias: [
{ find: '@', replacement: '/src/' },
{ find: 'vue', replacement: 'vue/dist/vue.esm-bundler.js' },
],
},
plugins: [
vue(),
svgicon({
include: ['**/icons/**/*.svg'],
}),
2021-07-13 16:15:03 +08:00
// legacy({
// targets: ['defaults', 'not IE 11'],
// }),
2021-07-29 00:01:45 +08:00
// viteStylelint(), // bugly
2021-07-09 18:28:29 +08:00
],
server: {
host: '0.0.0.0',
cors: true,
strictPort: true,
port: 9000,
hmr: {
// TODO: .env
protocol: 'ws',
host: 'localhost',
port: 9000,
},
fs: {
// This maybe MDC's incorrect absolute path
allow: ['./', './node_modules/', '/node_modules/'],
},
2021-07-09 18:28:29 +08:00
},
build: {
2021-07-13 11:27:58 +08:00
target: 'modules',
2021-07-09 18:28:29 +08:00
manifest: true,
sourcemap: true,
outDir: target === 'main' ? 'app/assets/main' : 'app/assets/admin',
2021-07-09 18:28:29 +08:00
chunkSizeWarningLimit: 2048,
2021-07-29 00:01:45 +08:00
// minify: false, // set false if use flex-gap-polyfill
2021-07-13 11:27:58 +08:00
rollupOptions: {
// external: ['vue'],
input: [path.resolve(__dirname, target === 'main' ? 'src/main.ts' : 'src/admin/main.ts')],
2021-07-13 11:27:58 +08:00
output: {
// TODO: use ES5 bundle instead
// globals: {
// vue: 'Vue',
// },
// manualChunks: undefined,
},
},
2021-07-09 18:28:29 +08:00
},
optimizeDeps: {
2021-07-29 00:01:45 +08:00
include: [
'gsap',
'marked',
'gsap/ScrollTrigger',
'highlight.js',
'@vueuse/core',
'perfect-scrollbar',
],
},
2021-07-09 18:28:29 +08:00
css: {
preprocessorOptions: {
scss: {
sassOptions: { quietDeps: true },
},
},
},
})