-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
66 lines (64 loc) · 1.63 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
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
const path = require("path");
const webpack = require("webpack");
const CopyPlugin = require("copy-webpack-plugin");
const FIGLET_FONT_NAME = "ANSI Shadow";
module.exports = {
mode: "production",
entry: {
"clydee-cli": [path.resolve(__dirname, "./bin/index.js")],
},
output: {
path: path.resolve(__dirname, "./dist/dist"), // figlet 找字体文件时的路径时../fonts, 为了把copy后的fonts文件也放在dist目录里,所以把主文件的入口加深一级
filename: "[name].js",
},
module: {
rules: [
{
oneOf: [
{
test: path.resolve(__dirname, "./bin/index.js"),
loader: "shebang2-loader",
},
{
test: /\.(js)$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
options: {
plugins: [["@babel/plugin-transform-runtime"]],
},
},
],
},
],
},
],
},
resolve: {
extensions: [".js", ".jsx", ".d.ts", ".ts", ".tsx"],
mainFiles: ["index"],
},
plugins: [
new webpack.BannerPlugin({ banner: "#!/usr/bin/env node", raw: true }),
new webpack.DefinePlugin({
FIGLET_FONT_NAME: JSON.stringify(FIGLET_FONT_NAME),
}),
new CopyPlugin([
{
from: path.resolve(
__dirname,
"node_modules",
"figlet",
"fonts",
`${FIGLET_FONT_NAME}.flf`
),
to: "../fonts", // figlet 找字体文件时的路径时../fonts
},
]),
],
target: "node",
node: {
__dirname: false,
},
};