csx/packages/csx-custom-elements/rollup.config.js

30 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', // immediately-invoked function expression — suitable for <script> tags
sourcemap: true
},
plugins: [
json(), // Add json support (sadly in rollup we have to do this explicity, despite the NodeJS algorithm supporitng this by defulat
babel(), // babel (the reason we're doing all of this, babel transpiling)
resolve({// node_modules (again we have to add support in rollup for something that is NodeJS default)
}),
commonjs({ // CJS-modules (require-style bundle support, again something rollup doesnt handle by default)
}),
production && terser() // minify, but only in production
],
external: [
]
};