generated from halo-dev/theme-starter
-
Notifications
You must be signed in to change notification settings - Fork 43
/
rollup.config.js
39 lines (35 loc) · 1.16 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
import resolve from "@rollup/plugin-node-resolve";
import { readdirSync } from "fs";
import { join as joinPath, resolve as resolvePath } from "path";
import postcss from "rollup-plugin-postcss";
import { terser } from "rollup-plugin-terser";
const jsRootDir = resolvePath(__dirname, "templates", "assets", "js");
const lessRootDir = resolvePath(__dirname, "templates", "assets", "css");
const jsFiles = readdirSync(jsRootDir).filter((file) => file.endsWith(".js"));
const lessFiles = readdirSync(lessRootDir).filter((file) =>
file.endsWith(".less")
);
const jsConfig = jsFiles.map((file) => ({
input: joinPath(jsRootDir, file),
output: {
file: joinPath(jsRootDir, "min", file.replace(".js", ".min.js")),
format: "iife",
},
plugins: [resolve(), terser()],
treeshake: false,
}));
const lessConfig = lessFiles.map((file) => ({
input: joinPath(lessRootDir, file),
output: {
file: joinPath(lessRootDir, "min", file.replace(".less", ".min.css")),
},
plugins: [
postcss({
extract: true,
minimize: true,
extensions: [".less"],
use: [["less", { javascriptEnabled: true }]],
}),
],
}));
export default [...jsConfig, ...lessConfig];