-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrollup.config.js
46 lines (44 loc) · 1.24 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import postcss from 'rollup-plugin-postcss'
import terser from '@rollup/plugin-terser'
import postcssNested from 'postcss-nested'
import pluginManifest from 'rollup-plugin-output-manifest'
const { default: outputManifest } = pluginManifest
// `npm run build` -> `production` is true
// `npm run local` -> `production` is false
const production = !process.env.ROLLUP_WATCH
export default [
{
input: 'javascripts/application.js',
output: {
name: 'application',
entryFileNames: '[hash][name].js',
dir: 'public/assets/javascript',
format: 'iife', // immediately-invoked function expression — suitable for <script> tags
sourcemap: false
},
plugins: [
nodeResolve(),
commonjs(),
production && terser(), // minify, but only in production
outputManifest()
]
},
{
input: 'styles/application.scss',
output: {
name: 'application',
entryFileNames: '[hash][name].css',
dir: 'public/assets/styles'
},
plugins: [
outputManifest(),
postcss({
extract: true,
minimize: production,
plugins: [postcssNested]
})
]
}
]