59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import { defineConfig } from 'tsup'
|
|
import * as preset from 'tsup-preset-solid'
|
|
|
|
const preset_options: preset.PresetOptions = {
|
|
// array or single object
|
|
entries: [
|
|
// default entry (index)
|
|
{
|
|
// entries with '.tsx' extension will have `solid` export condition generated
|
|
entry: 'src/index.ts',
|
|
// will generate a separate development entry
|
|
dev_entry: true,
|
|
},
|
|
],
|
|
// Set to `true` to remove all `console.*` calls and `debugger` statements in prod builds
|
|
drop_console: true,
|
|
// Set to `true` to generate a CommonJS build alongside ESM
|
|
// cjs: true,
|
|
}
|
|
|
|
const CI =
|
|
process.env['CI'] === 'true' ||
|
|
process.env['GITHUB_ACTIONS'] === 'true' ||
|
|
process.env['CI'] === '"1"' ||
|
|
process.env['GITHUB_ACTIONS'] === '"1"'
|
|
|
|
export default defineConfig(config => {
|
|
const watching = !!config.watch
|
|
|
|
const parsed_options = preset.parsePresetOptions(preset_options, watching)
|
|
|
|
if (!watching && !CI) {
|
|
const package_fields = preset.generatePackageExports(parsed_options)
|
|
const export_keys = Object.keys(package_fields.exports || {})
|
|
const is_condition_exports = export_keys.length > 0 && export_keys.every(key => !key.startsWith('.'))
|
|
if (is_condition_exports) {
|
|
package_fields.exports = {
|
|
'.': package_fields.exports,
|
|
'./styles/*': './dist/styles/*',
|
|
}
|
|
} else {
|
|
package_fields.exports = {
|
|
...package_fields.exports,
|
|
'./styles/*': './dist/styles/*',
|
|
}
|
|
}
|
|
|
|
console.log(`package.json: \n\n${JSON.stringify(package_fields, null, 2)}\n\n`)
|
|
|
|
// will update ./package.json with the correct export fields
|
|
preset.writePackageJson(package_fields)
|
|
}
|
|
|
|
return preset.generateTsupOptions(parsed_options).map(opts => ({
|
|
...opts,
|
|
// minify: !watching,
|
|
}));
|
|
})
|