29 lines
1.3 KiB
JavaScript
29 lines
1.3 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)
|
|
dedupe: [ '@babel/core', "@babel/helper-plugin-utils", "@babel/plugin-syntax-jsx", "@babel/helper-builder-react-jsx" , "@babel/types"]
|
|
}),
|
|
commonjs({ // CJS-modules (require-style bundle support, again something rollup doesnt handle by default)
|
|
}),
|
|
production && terser() // minify, but only in production
|
|
],
|
|
external: ['@babel/core','@babel/traverse', "@babel/types" ]
|
|
}; |