forked from daostack/alchemy
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.base.config.js
132 lines (120 loc) · 4 KB
/
webpack.base.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ENV = process.env.NODE_ENV || "development";
const isProd = ENV === "production";
const isDev = ENV === "development";
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const basePath = process.cwd();
const resolve = (pat) => path.resolve(basePath, pat)
module.exports = {
devtool: "eval",
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
alias: {
arc: resolve("src/arc"),
actions: resolve("src/actions"),
components: resolve("src/components"),
constants: resolve("src/constants"),
data: resolve("data"),
genericSchemeRegistry: resolve("src/genericSchemeRegistry"),
crxRegistry: resolve("src/crxRegistry"),
layouts: resolve("src/layouts"),
lib: resolve("src/lib"),
pages: resolve("src/pages"),
reducers: resolve("src/reducers"),
selectors: resolve("src/selectors"),
src: resolve("src"),
"ipfs-api": "ipfs-api/dist",
"bn.js": "bn.js/lib/bn.js"
}
},
module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{
test: /\.tsx?$/,
loader: ["react-hot-loader/webpack", "awesome-typescript-loader"],
exclude: [/node_modules/, /\.spec\.ts$/]
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader",
exclude: [
resolve("node_modules/apollo-cache-inmemory"),
resolve("node_modules/apollo-client"),
resolve("node_modules/apollo-link"),
resolve("node_modules/apollo-link-http"),
resolve("node_modules/apollo-link-ws"),
resolve("node_modules/ethereumjs-common"),
resolve("node_modules/ethereumjs-tx"),
resolve("node_modules/ethereumjs-util"),
resolve("node_modules/graphql-request"),
resolve("node_modules/https-did-resolver"),
resolve("node_modules/rlp"),
resolve("node_modules/subscriptions-transport-ws"),
resolve("node_modules/xhr2-cookies"),
resolve("node_modules/zen-observable-ts"),
resolve("node_modules/@dorgtech")
]
},
// This handle the CSS coming from dao creator
{
test: /\.css$/,
include: [
resolve("node_modules/@fortawesome/fontawesome-free/css/all.min.css"),
resolve("node_modules/mdbreact/dist/css/mdb.css"),
resolve("node_modules/@dorgtech/daocreator-ui/dist")
],
use: [MiniCssExtractPlugin.loader, "css-loader"]
},
// CSS handling
{
test: /\.css$/,
include: /client/,
exclude: /node_modules/,
use: [
"style-loader",
{
// translates CSS into CommonJS (css-loader) and automatically generates TypeScript types
loader: "typings-for-css-modules-loader",
options: {
camelCase: true,
localIdentName: "[name]__[local]___[hash:base64:5]",
minimize: isProd,
modules: true,
namedExport: true,
sourceMap: true
}
}
]
},
// Images & fonts
{
test: /\.(png|jpg|gif|mp4|ogg|svg|woff|woff2|ttf|eot|ico)$/,
loader: "url-loader",
options: {
limit: 10000 // For assets smaller than 10k inline them as data urls, otherwise use regular file loader
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: "src/index.html"
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(require("./package.json").version)
}),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new MiniCssExtractPlugin()
],
node: {
fs: "empty",
net: "empty",
tls: "empty"
}
};