2022-02-15 00:33:16 -07:00
|
|
|
// vite.config.js
|
2022-02-15 16:30:30 -07:00
|
|
|
'use strict';
|
|
|
|
|
2022-02-15 00:33:16 -07:00
|
|
|
const path = require('path');
|
|
|
|
const { defineConfig } = require('vite');
|
|
|
|
|
|
|
|
module.exports = defineConfig({
|
2022-02-23 20:25:05 -07:00
|
|
|
// We have to specify this otherwise Vite will override NODE_ENV as
|
|
|
|
// `production` when we start the server and watch build in our `start-dev.js`.
|
|
|
|
mode: process.env.NODE_ENV || 'dev',
|
|
|
|
|
2022-02-15 00:33:16 -07:00
|
|
|
//root: './',
|
|
|
|
//base: './',
|
|
|
|
outDir: './dist',
|
|
|
|
// optimizeDeps: {
|
|
|
|
// include: ['matrix-public-archive-shared'],
|
|
|
|
// },
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
// The `file:` packages don't seem resolve correctly so let's add an alias as well
|
|
|
|
// See https://css-tricks.com/adding-vite-to-your-existing-web-app/#aa-aliases
|
|
|
|
'matrix-public-archive-shared': path.resolve(__dirname, './shared'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
build: {
|
|
|
|
// Fix `Error: 'default' is not exported by ...` when importin CommonJS files,
|
|
|
|
// see https://github.com/vitejs/vite/issues/2679
|
|
|
|
commonjsOptions: { include: [] },
|
|
|
|
|
|
|
|
lib: {
|
|
|
|
entry: path.resolve(__dirname, './public/js/entry-client.js'),
|
|
|
|
//formats: ['cjs'],
|
|
|
|
name: 'MatrixPublicArchive',
|
|
|
|
fileName: (format) => `matrix-public-archive.${format}.js`,
|
|
|
|
},
|
|
|
|
rollupOptions: {},
|
|
|
|
},
|
|
|
|
});
|