-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
81 lines (78 loc) · 2.15 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import alias from '@rollup/plugin-alias';
import commonjs from '@rollup/plugin-commonjs';
import html from '@rollup/plugin-html';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import url from '@rollup/plugin-url';
import autoprefixer from 'autoprefixer';
import copy from 'rollup-plugin-copy';
import livereload from 'rollup-plugin-livereload';
import postcss from 'rollup-plugin-postcss';
import serve from 'rollup-plugin-serve';
import indexHtmlTemplate from './public/index.html.js';
import babel from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import cssnano from 'cssnano';
const isProd = process.env.NODE_ENV === "production";
const outputDir = 'build';
export default {
input: 'src/main.ts',
output: {
dir: outputDir,
format: 'es',
sourcemap: true,
},
watch: {
chokidar: {
paths: 'src/**'
},
buildDelay: 1000, // TODO: Adjust build delay time as u needed.
clearScreen: false,
},
plugins: [
alias({
entries: [
{ find: '@assets', replacement: 'public/assets' }
]
}),
babel({ babelHelpers: 'bundled' }),
commonjs(),
typescript(),
url({
include: ['**/*.png'], // Adjust the glob pattern based on your asset file extensions
limit: 0, // Disable base64 encoding
publicPath: '/assets/', // Adjust the public path based on your project setup
destDir: `${outputDir}/assets/`,
}),
copy({
targets: [
{ src: 'public/static/*', dest: outputDir },
]
}),
nodeResolve(),
postcss({
namedExports: (name) => name.replace(/[-_]+([a-z])/g, (match, letter) => letter.toUpperCase()),
plugins: [autoprefixer(), cssnano()],
modules: true,
extract: true,
sourceMap: !isProd,
minimize: !isProd,
use: ['sass'],
}),
html({
title: 'Boilerplate',
// @ts-ignore
template: indexHtmlTemplate
}),
!isProd && serve({
contentBase: outputDir,
open: true,
verbose: true,
}),
!isProd && livereload({
watch: outputDir,
verbose: true,
}),
isProd && terser(),
],
};