-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.config.js
41 lines (36 loc) · 1.36 KB
/
webpack.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
import path from "path";
import fs from "fs";
import { fileURLToPath } from "url";
import { readFileSync } from "fs";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const packageJsonPath = path.resolve(__dirname, "package.json");
const packageJsonContent = readFileSync(packageJsonPath, "utf-8");
const { version } = JSON.parse(packageJsonContent);
export default {
mode: "production",
entry: "./cdn.js",
output: {
filename: `mojo.min.js`,
path: path.resolve(__dirname, "dist"),
},
optimization: {
mangleWasmImports: true,
concatenateModules: false,
},
plugins: [
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap("AddCommentsPlugin", () => {
const outputPath = path.resolve(__dirname, "dist", "mojo.min.js");
setTimeout(() => {
const comment = `/* Mojo CSS ${version} (https://mojocss.com) | Copyright © 2024 Mojo CSS Authors (https://github.com/orgs/mojocss/people) | Licensed under MIT (https://github.com/mojocss/mojocss/blob/main/LICENSE) */`;
const fileContent = fs.readFileSync(outputPath, "utf-8");
const contentWithComment = comment + "\n" + fileContent;
fs.writeFileSync(outputPath, contentWithComment, "utf8");
console.log("Comment added to the beginning of the file.");
}, 100);
});
},
},
],
};