|
| 1 | +import vue from 'rollup-plugin-vue'; |
| 2 | +import commonjs from 'rollup-plugin-commonjs'; |
| 3 | +import resolve from 'rollup-plugin-node-resolve'; |
| 4 | +import { terser } from 'rollup-plugin-terser'; |
| 5 | +import css from 'rollup-plugin-css-only'; |
| 6 | +import pckg from './package.json'; |
| 7 | + |
| 8 | +// Dynamic module config |
| 9 | +const inputFile = pckg.plugin.entryFile; |
| 10 | +const BrowserNamePackage = pckg.plugin.name; |
| 11 | +const ModuleNamePackage = pckg.name; |
| 12 | + |
| 13 | +const config = [ |
| 14 | + // ESM build to be used with webpack/rollup. |
| 15 | + { |
| 16 | + input: inputFile, |
| 17 | + output: { |
| 18 | + format: 'esm', |
| 19 | + exports: 'named', |
| 20 | + name: ModuleNamePackage, |
| 21 | + file: `dist/${ModuleNamePackage}.esm.js`, |
| 22 | + }, |
| 23 | + plugins: [ |
| 24 | + resolve({ |
| 25 | + extensions: ['.js', '.vue'], |
| 26 | + }), |
| 27 | + commonjs(), |
| 28 | + vue(), |
| 29 | + ], |
| 30 | + }, |
| 31 | + // Common Js |
| 32 | + { |
| 33 | + input: inputFile, |
| 34 | + output: { |
| 35 | + format: 'cjs', |
| 36 | + exports: 'named', |
| 37 | + name: ModuleNamePackage, |
| 38 | + file: `dist/${ModuleNamePackage}.cjs.js`, |
| 39 | + }, |
| 40 | + plugins: [ |
| 41 | + resolve({ |
| 42 | + extensions: ['.js', '.vue'], |
| 43 | + }), |
| 44 | + commonjs(), |
| 45 | + vue(), |
| 46 | + ], |
| 47 | + }, |
| 48 | + // SSR Build |
| 49 | + { |
| 50 | + input: inputFile, |
| 51 | + output: { |
| 52 | + format: 'cjs', |
| 53 | + exports: 'named', |
| 54 | + name: ModuleNamePackage, |
| 55 | + file: `dist/${ModuleNamePackage}.ssr.js`, |
| 56 | + }, |
| 57 | + plugins: [ |
| 58 | + resolve({ |
| 59 | + extensions: ['.js', '.vue'], |
| 60 | + }), |
| 61 | + commonjs(), |
| 62 | + vue({ template: { optimizeSSR: true } }), |
| 63 | + ], |
| 64 | + }, |
| 65 | + // Browser build |
| 66 | + { |
| 67 | + input: inputFile, |
| 68 | + output: { |
| 69 | + format: 'iife', |
| 70 | + exports: 'named', |
| 71 | + name: BrowserNamePackage, |
| 72 | + file: `dist/${ModuleNamePackage}.js`, |
| 73 | + }, |
| 74 | + plugins: [ |
| 75 | + resolve({ |
| 76 | + extensions: ['.js', '.vue'], |
| 77 | + }), |
| 78 | + commonjs(), |
| 79 | + css(), |
| 80 | + vue({ css: false }), |
| 81 | + terser(), |
| 82 | + ], |
| 83 | + }, |
| 84 | +]; |
| 85 | + |
| 86 | +export default config; |
0 commit comments