forked from tlgreg/svelte-tailwindcss-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
45 lines (43 loc) · 1.17 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
import purgeCss from '@fullhuman/postcss-purgecss'
import autoprefixer from 'autoprefixer'
import postcssImport from 'postcss-import'
import commonjs from 'rollup-plugin-commonjs'
import livereload from 'rollup-plugin-livereload'
import resolve from 'rollup-plugin-node-resolve'
import postcss from 'rollup-plugin-postcss'
import svelte from 'rollup-plugin-svelte'
import { terser } from 'rollup-plugin-terser'
import tailwind from 'tailwindcss'
const production = !process.env.ROLLUP_WATCH
const removeUnusedCss = purgeCss({
content: ['./src/**/*.html', './src/**/*.svelte'],
defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || [],
})
export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/bundle.js',
},
plugins: [
svelte({
dev: !production,
emitCss: true,
}),
postcss({
plugins: [
postcssImport,
tailwind(),
autoprefixer,
production && removeUnusedCss,
].filter(Boolean),
extract: 'public/bundle.css',
}),
resolve(),
commonjs(),
!production && livereload('public'),
production && terser(),
],
}