forked from alex-shpak/hugo-book
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.mjs
48 lines (46 loc) · 1.68 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
import commonjs from "@rollup/plugin-commonjs";
import css from "rollup-plugin-import-css";
import nodeResolve from "@rollup/plugin-node-resolve";
import postcss from "rollup-plugin-postcss";
import babel from "@rollup/plugin-babel";
import atImport from "postcss-import";
import postcssPresetEnv from "postcss-preset-env";
import copy from "rollup-plugin-copy";
import terser from "@rollup/plugin-terser";
import replace from "@rollup/plugin-replace";
import { visualizer } from "rollup-plugin-visualizer";
const sourceMap = process.env.NODE_ENV.trim() === "dev";
export default {
input: { main: "src/assets/js/main.js", map: "src/assets/js/map.js" },
output: { dir: "dist/assets/", sourcemap: sourceMap, format: "es" },
plugins: [
replace({
"process.env.NODE_ENV": JSON.stringify("production"),
preventAssignment: true,
}),
nodeResolve(),
commonjs(),
babel({ babelHelpers: "bundled" }),
postcss({
extract: true,
sourceMap: sourceMap,
extensions: ["css", "scss"],
plugins: [atImport(), postcssPresetEnv()],
minimize: true,
}),
css(),
copy({
targets: [
{ src: "src/assets/fonts", dest: "dist/assets/" },
{ src: "src/assets/img", dest: "dist/assets/" },
{ src: "src/assets/svg", dest: "dist/assets/" },
{ src: "src/assets/js/*.json", dest: "dist/assets/" },
],
}),
terser(),
visualizer({
filename: "dist/statistics.html",
}),
// del({ targets: 'dist/*' })
],
};