2020-05-07 19:34:28 +00:00
|
|
|
import resolve from '@rollup/plugin-node-resolve'
|
|
|
|
import commonjs from '@rollup/plugin-commonjs'
|
2020-05-08 19:42:36 +00:00
|
|
|
import replace from '@rollup/plugin-replace'
|
2020-05-07 19:34:28 +00:00
|
|
|
import { terser } from 'rollup-plugin-terser'
|
|
|
|
|
2020-05-08 19:42:36 +00:00
|
|
|
// 'npm run watch:js' -> 'production' is false
|
|
|
|
// 'npm run build:js' -> 'production' is true
|
2020-05-07 19:34:28 +00:00
|
|
|
const production = !process.env.ROLLUP_WATCH
|
|
|
|
|
|
|
|
export default {
|
|
|
|
input: 'src/js/app.js',
|
|
|
|
output: [
|
|
|
|
{
|
|
|
|
file: 'public/js/bundle.js',
|
|
|
|
format: 'module',
|
|
|
|
sourcemap: true
|
|
|
|
}
|
|
|
|
],
|
|
|
|
plugins: [
|
2020-05-08 19:42:36 +00:00
|
|
|
// Needed for Vue imports, could use alias plugin but they're not working with resolve plugin
|
|
|
|
// Assuming all the Vue imports are made like: import Vue from 'vue.esm' (vue.esm is made for bundlers)
|
|
|
|
replace({
|
|
|
|
'process.env.NODE_ENV': JSON.stringify(production ? 'production' : 'development')
|
|
|
|
}),
|
2020-05-07 19:34:28 +00:00
|
|
|
resolve(), // Tells Rollup how to find imported modules in node_modules
|
|
|
|
commonjs(), // Converts imported modules to ES modules, if necessary
|
|
|
|
production && terser() // Minify, but only in production
|
|
|
|
]
|
|
|
|
}
|