(
config: UserConfig,
projectDir: string,
name: string,
entry: string,
withMin: boolean = true
)
| 234 | } |
| 235 | |
| 236 | export function umd( |
| 237 | config: UserConfig, |
| 238 | projectDir: string, |
| 239 | name: string, |
| 240 | entry: string, |
| 241 | withMin: boolean = true |
| 242 | ) { |
| 243 | const lib = config.build!.lib! as LibraryOptions; |
| 244 | lib.entry = { |
| 245 | [name]: path.resolve(projectDir, entry) |
| 246 | }; |
| 247 | |
| 248 | (config.build!.rollupOptions!.output as OutputOptions[]).push({ |
| 249 | globals: { |
| 250 | jQuery: 'jQuery' |
| 251 | }, |
| 252 | dir: 'dist/', |
| 253 | format: 'umd', |
| 254 | name: name, |
| 255 | entryFileNames: '[name].js', |
| 256 | chunkFileNames: '[name].js' |
| 257 | }); |
| 258 | |
| 259 | if (withMin) { |
| 260 | for (const output of config.build!.rollupOptions!.output as OutputOptions[]) { |
| 261 | output.plugins ??= []; |
| 262 | (output.plugins as OutputPlugin[]).push(min(terserOptions)); |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | export function commonjs(config: UserConfig, projectDir: string, name: string, entry: string) { |
| 268 | const lib = config.build!.lib! as LibraryOptions; |
no test coverage detected