2020-05-07 19:34:28 +00:00
|
|
|
import resolve from '@rollup/plugin-node-resolve'
|
2020-06-03 16:31:38 +00:00
|
|
|
import { terser } from 'rollup-plugin-terser'
|
2020-05-07 19:34:28 +00:00
|
|
|
import commonjs from '@rollup/plugin-commonjs'
|
2020-05-08 19:42:36 +00:00
|
|
|
import replace from '@rollup/plugin-replace'
|
2020-05-22 20:59:16 +00:00
|
|
|
import alias from '@rollup/plugin-alias'
|
2020-06-03 16:31:38 +00:00
|
|
|
import analyze from 'rollup-plugin-analyzer'
|
2020-05-07 19:34:28 +00:00
|
|
|
|
2020-05-22 22:15:29 +00:00
|
|
|
// 'rollup -c' -> 'production' is false
|
|
|
|
// 'rollup -c -w' -> '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',
|
2020-06-07 19:06:52 +00:00
|
|
|
sourcemap: !production
|
2020-05-07 19:34:28 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
plugins: [
|
2020-05-22 20:59:16 +00:00
|
|
|
alias({
|
|
|
|
entries: [
|
|
|
|
{
|
|
|
|
find: 'vue',
|
|
|
|
replacement: 'vue/dist/vue.esm'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
// Needed for Vue imports
|
2020-05-08 19:42:36 +00:00
|
|
|
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
|
2020-06-03 16:31:38 +00:00
|
|
|
production && terser(), // Minify, but only in production
|
2020-06-03 18:49:19 +00:00
|
|
|
production && analyze({ showExports: true, limit: 15 }) // Show useful information about bundles, only in production
|
2020-05-07 19:34:28 +00:00
|
|
|
]
|
|
|
|
}
|