-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrollup.config.mjs
66 lines (64 loc) · 1.74 KB
/
rollup.config.mjs
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import copy from 'rollup-plugin-copy';
import styles from "rollup-plugin-styler";
const paths = {
src: 'app/assets/',
dist: 'app/static/',
npm: 'node_modules/',
govuk_frontend: 'node_modules/govuk-frontend/dist/govuk/'
};
export default [
// ESM compilation and copy static assets
{
input: paths.src + 'javascripts/main.mjs',
output: {
dir: paths.dist + 'javascripts/',
entryFileNames: 'main.js',
format: 'es',
sourcemap: true
},
plugins: [
nodeResolve(),
terser(),
// copy images, error pages and govuk-frontend static assets
copy({
targets: [
{ src: [ paths.src + 'images/**/*', paths.govuk_frontend + 'assets/images/**/*' ], dest: paths.dist + 'images/' },
{ src: paths.govuk_frontend + 'assets/fonts/**/*', dest: paths.dist + 'fonts/' },
{ src: paths.govuk_frontend + 'assets/manifest.json', dest: paths.dist }
]
}),
]
},
// SCSS compilation
{
input: paths.src + 'stylesheets/main.scss',
output: {
dir: paths.dist + 'stylesheets/',
assetFileNames: "[name][extname]",
},
plugins: [
// https://anidetrix.github.io/rollup-plugin-styles/interfaces/types.Options.html
styles({
mode: "extract",
sass: {
includePaths: [
paths.govuk_frontend,
paths.npm
],
silenceDeprecations: [
"mixed-decls",
"global-builtin",
"color-functions",
"slash-div",
"import"
],
},
minimize: true,
url: false,
sourceMap: true,
}),
]
}
];