2023-06-21 12:50:06 +00:00
|
|
|
const path = require('path');
|
|
|
|
const { defineConfig } = require('vitest/config');
|
|
|
|
const { default: eslint } = require('vite-plugin-eslint');
|
|
|
|
const dts = require('vite-plugin-dts');
|
2023-09-06 17:43:45 +00:00
|
|
|
const pkg = require('./package.json');
|
2023-09-10 17:45:20 +00:00
|
|
|
const fs = require('fs/promises');
|
2023-06-21 12:50:06 +00:00
|
|
|
|
2024-01-17 16:18:12 +00:00
|
|
|
const shouldTestProviders = process.env.MW_TEST_PROVIDERS === "true"
|
|
|
|
let tests = ['src/__test__/standard/**/*.test.ts'];
|
|
|
|
if (shouldTestProviders) tests = ['src/__test__/providers/**/*.test.ts']
|
2023-06-21 13:12:45 +00:00
|
|
|
|
2023-06-21 12:50:06 +00:00
|
|
|
module.exports = defineConfig({
|
2023-09-10 17:45:20 +00:00
|
|
|
plugins: [
|
|
|
|
eslint(),
|
|
|
|
dts({
|
|
|
|
rollupTypes: true,
|
|
|
|
async afterBuild() {
|
|
|
|
const filePath = path.join(__dirname, './lib/index.d.ts');
|
|
|
|
await fs.writeFile(filePath.replace('.d.ts', '.d.mts'), await fs.readFile(filePath, 'utf-8'), 'utf-8');
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
2023-06-21 12:50:06 +00:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': path.resolve(__dirname, './src'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
build: {
|
2023-06-21 13:12:45 +00:00
|
|
|
minify: false,
|
2023-09-06 17:43:45 +00:00
|
|
|
rollupOptions: {
|
|
|
|
external: Object.keys(pkg.dependencies),
|
|
|
|
output: {
|
|
|
|
globals: Object.fromEntries(Object.keys(pkg.dependencies).map((v) => [v, v])),
|
|
|
|
},
|
|
|
|
},
|
2023-06-21 12:50:06 +00:00
|
|
|
outDir: 'lib',
|
2023-06-21 13:12:45 +00:00
|
|
|
|
2023-06-21 12:50:06 +00:00
|
|
|
lib: {
|
2024-01-17 16:18:12 +00:00
|
|
|
entry: path.resolve(__dirname, 'src/index.ts'),
|
2023-08-27 18:47:48 +00:00
|
|
|
name: 'index',
|
|
|
|
fileName: 'index',
|
2023-09-06 17:43:45 +00:00
|
|
|
formats: ['umd', 'es'],
|
2023-06-21 12:50:06 +00:00
|
|
|
},
|
|
|
|
},
|
2024-01-17 16:18:12 +00:00
|
|
|
test: {
|
|
|
|
include: tests
|
|
|
|
}
|
2023-06-21 12:50:06 +00:00
|
|
|
});
|