forked from BuilderIO/figma-html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
82 lines (80 loc) · 2.01 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const webpack = require("webpack");
const HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
module.exports = (env, argv) => {
const baseConfig = {
mode: argv.mode === "production" ? "production" : "development",
devtool: false,
module: {
rules: [
{ test: /\.tsx?$/, use: "ts-loader", exclude: /node_modules/ },
{
test: /\.css$/,
loader: [{ loader: "style-loader" }, { loader: "css-loader" }],
},
{
test: /\.(png|jpg|gif|webp|svg)$/,
loader: [{ loader: "url-loader" }],
},
],
},
resolve: { extensions: [".tsx", ".ts", ".jsx", ".js"] },
output: {
path: path.resolve(__dirname, "dist"),
},
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: "production",
API_KEY: null,
}),
],
};
return [
{
...baseConfig,
entry: {
ui: "./plugin/ui.tsx", // The entry point for your UI code
code: "./plugin/code.ts",
},
output: {
...baseConfig.output,
filename: "[name].js",
},
plugins: [
...baseConfig.plugins,
new HtmlWebpackPlugin({
template: "./plugin/ui.html",
filename: "ui.html",
inlineSource: ".(js)$",
chunks: ["ui"],
}),
new HtmlWebpackInlineSourcePlugin(),
],
},
{
...baseConfig,
entry: "./lib/html-to-figma/index.ts",
output: {
...baseConfig.output,
library: "htmlToFigma",
libraryTarget: "var",
filename: "browser.js",
},
},
{
...baseConfig,
optimization: {
minimize: false,
},
entry: "./lib/html-to-figma/index.ts",
output: {
...baseConfig.output,
library: "htmlToFigma",
libraryExport: "htmlToFigma",
libraryTarget: "commonjs",
filename: "main.js",
},
},
];
};