hippofish/packages/client/vite.config.ts

81 lines
2.1 KiB
TypeScript
Raw Normal View History

2022-04-22 09:11:34 +02:00
import * as fs from 'fs';
import pluginVue from '@vitejs/plugin-vue';
2022-04-22 19:54:51 +02:00
import pluginJson5 from './vite.json5';
import pluginNode from '@rollup/plugin-node-resolve';
import pluginCjs from '@rollup/plugin-commonjs';
2022-04-22 09:11:34 +02:00
import { defineConfig } from 'vite';
2022-04-22 17:57:28 +02:00
const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json', '.json5', '.svg', '.sass', '.scss', '.css', '.vue'];
2022-04-22 09:11:34 +02:00
const isProduction = process.env.NODE_ENV === 'production';
const locales = require('../../locales');
const meta = require('../../package.json');
export default defineConfig(({ command, mode }) => {
fs.mkdirSync(__dirname + '/../../built', { recursive: true });
fs.writeFileSync(__dirname + '/../../built/meta.json', JSON.stringify({ version: meta.version }), 'utf-8');
return {
base: '/assets/',
plugins: [
pluginVue({
reactivityTransform: true,
}),
2022-04-22 19:54:51 +02:00
pluginNode({
//extensions,
}),
pluginCjs({
transformMixedEsModules: true,
extensions: ['.json', '.json5'],
}),
pluginJson5(),
2022-04-22 09:11:34 +02:00
],
resolve: {
extensions,
2022-04-22 17:57:28 +02:00
alias: {
'@/': __dirname + '/src/',
'/client-assets/': __dirname + '/assets/',
'/static-assets/': __dirname + '/../backend/assets/',
},
2022-04-22 09:11:34 +02:00
},
define: {
_VERSION_: JSON.stringify(meta.version),
_LANGS_: JSON.stringify(Object.entries(locales).map(([k, v]) => [k, v._lang_])),
_ENV_: JSON.stringify(process.env.NODE_ENV),
_DEV_: process.env.NODE_ENV !== 'production',
_PERF_PREFIX_: JSON.stringify('Misskey:'),
_DATA_TRANSFER_DRIVE_FILE_: JSON.stringify('mk_drive_file'),
_DATA_TRANSFER_DRIVE_FOLDER_: JSON.stringify('mk_drive_folder'),
_DATA_TRANSFER_DECK_COLUMN_: JSON.stringify('mk_deck_column'),
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false,
},
build: {
2022-04-22 18:50:20 +02:00
target: [
'chrome100',
'firefox100',
'safari15',
],
2022-04-22 09:11:34 +02:00
manifest: true,
rollupOptions: {
input: {
app: './src/init.ts',
2022-04-22 17:57:28 +02:00
},
output: {
manualChunks: {
vue: ['vue', 'vue-router', 'vuedraggable'],
},
},
2022-04-22 09:11:34 +02:00
},
2022-04-22 18:50:20 +02:00
outDir: __dirname + '/../../built',
assetsDir: '_client_dist_',
emptyOutDir: false,
2022-04-22 09:11:34 +02:00
},
}
});