46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { defineConfig } from 'tsup'
|
|
import { readFileSync } from 'fs'
|
|
import conditionalBuild from 'esbuild-plugin-conditional-build'
|
|
import { sassPlugin } from 'esbuild-sass-plugin'
|
|
import postcss from 'postcss';
|
|
import autoprefixer from 'autoprefixer';
|
|
import postcssPresetEnv from 'postcss-preset-env';
|
|
|
|
const buildSettings = JSON.parse(readFileSync('build-settings.json'))
|
|
const playerPlugins: string[] = []
|
|
|
|
for (const property in buildSettings.plugins) {
|
|
if (buildSettings.plugins[property]) {
|
|
playerPlugins.push(property)
|
|
}
|
|
}
|
|
|
|
export default defineConfig((options) => {
|
|
const isDev = options.env.NODE_ENV !== 'production'
|
|
return {
|
|
globalName: 'VokaPlayer',
|
|
entry: {
|
|
vokaPlayer: 'src/main.ts'
|
|
},
|
|
format: ['iife'],
|
|
outDir: 'demo/distribution',
|
|
dts: false,
|
|
splitting: false,
|
|
sourcemap: isDev,
|
|
clean: true,
|
|
minify: isDev ? false : 'terser',
|
|
treeshake: true,
|
|
bundle: true,
|
|
injectStyle: true,
|
|
esbuildPlugins: [
|
|
conditionalBuild(playerPlugins),
|
|
sassPlugin({
|
|
type: 'style',
|
|
async transform(source, resolveDir) {
|
|
const {css} = await postcss([autoprefixer, postcssPresetEnv({stage: 0})]).process(source, {from: undefined})
|
|
return css
|
|
}
|
|
})
|
|
]
|
|
}
|
|
}) |