37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import babel from 'rollup-plugin-babel';
|
|
import resolve from 'rollup-plugin-node-resolve';
|
|
import commonjs from 'rollup-plugin-commonjs';
|
|
import { terser } from 'rollup-plugin-terser';
|
|
import json from "rollup-plugin-json";
|
|
// `npm run build` -> `production` is true
|
|
// `npm run dev` -> `production` is false
|
|
const production = !process.env.ROLLUP_WATCH;
|
|
|
|
export default {
|
|
input: 'src/index.js',
|
|
output: {
|
|
file: 'dist/index.js',
|
|
format: 'cjs', // common-js bundle as would be expected for node
|
|
sourcemap: true
|
|
},
|
|
plugins: [
|
|
// Add json support (sadly in rollup we have to do this explicity, despite the NodeJS algorithm supporitng this by defulat
|
|
json(),
|
|
// babel
|
|
babel(),
|
|
// node_modules
|
|
resolve({
|
|
preferBuiltins: true,
|
|
extensions: ['.mjs', '.js', '.jsx', '.json'],
|
|
}),
|
|
// CJS-modules
|
|
commonjs({
|
|
'minimatch': ['Minimatch'],
|
|
}),
|
|
// minify, but only in production
|
|
production && terser()
|
|
],
|
|
external: [
|
|
|
|
]
|
|
}; |