forked from Gandi-IDE/gandi-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
100 lines (99 loc) · 2.44 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = {
mode: "production",
entry: {
main: "./src/main.ts",
playground: "./src/index.tsx",
},
output: {
path: path.join(__dirname, "dist"),
libraryTarget: "umd",
library: "GandiPlugins",
filename: "static/js/[name].js",
chunkFilename: "[name].[hash:5].js",
clean: true, // Clean the output directory before emit.
},
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.less$/,
use: [
"style-loader",
{
loader: "@teamsupercell/typings-for-css-modules-loader",
},
{
loader: "css-loader",
options: {
sourceMap: true,
modules: {
localIdentName: "addons_[local]_[hash:base64:5]",
exportLocalsConvention: "camelCaseOnly",
},
},
},
{
loader: "postcss-loader",
},
{
loader: "less-loader",
},
],
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.svg$/i,
type: "asset",
resourceQuery: /url/, // *.svg?url
},
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
resourceQuery: { not: [/url/] }, // exclude react component if *.svg?url
use: ["@svgr/webpack"],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
alias: {
src: path.resolve(__dirname, "./src"),
plugins: path.resolve(__dirname, "./src/plugins"),
assets: path.resolve(__dirname, "./src/assets"),
lib: path.resolve(__dirname, "./src/lib"),
utils: path.resolve(__dirname, "./src/utils"),
components: path.resolve(__dirname, "./src/components"),
hooks: path.resolve(__dirname, "./src/hooks"),
types: path.resolve(__dirname, "./src/types"),
},
},
plugins: [
new HtmlWebpackPlugin({
chunks: ["playground"],
template: "./index.html",
title: "Gandi Plugins",
}),
new CopyWebpackPlugin({
patterns: [
{
from: "./favicon.ico",
to: "./",
},
],
}),
],
optimization: {
minimize: true,
},
target: ["web", "es6"],
};