generated from TryGhost/Starter
-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.js
51 lines (48 loc) · 1.25 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
47
48
49
50
51
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';
import replace from 'rollup-plugin-replace';
// CSS
import postcss from 'rollup-plugin-postcss';
import atImport from 'postcss-import';
import postcssPresetEnv from 'postcss-preset-env';
import cssnano from 'cssnano';
const postcssConfig = postcss({
extract: true,
sourceMap: true,
plugins: [
atImport,
postcssPresetEnv({ features: { 'nesting-rules': true } }),
process.env.NODE_ENV === 'production' && cssnano({ preset: 'default' }),
],
});
const plugins = [
commonjs(),
nodeResolve(),
babel({ exclude: 'node_modules/**', babelHelpers: 'bundled' }),
process.env.NODE_ENV === 'production' && terser(),
replace({
ENV: JSON.stringify(process.env.NODE_ENV || 'production'),
}),
];
export default [
{
input: 'src/js/app/index.js',
output: {
file: 'assets/dist/app.js',
format: 'iife',
sourcemap: true,
},
plugins: [...plugins, postcssConfig],
},
{
input: 'src/js/post/index.js',
output: {
file: 'assets/dist/post.js',
format: 'iife',
sourcemap: true,
},
plugins,
},
];