-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
112 lines (105 loc) · 2.67 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
101
102
103
104
105
106
107
108
109
110
111
112
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const createStyledComponentsTransformer = require('typescript-plugin-styled-components')
.default;
const styledComponentsTransformer = createStyledComponentsTransformer();
module.exports = {
mode: 'production',
entry: {
'bundle.js': __dirname + '/src/index.tsx',
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.min.js',
publicPath: '/',
},
// Enable sourcemaps for debugging webpack's output.
devtool: 'source-map',
devServer: {
port: 5000,
historyApiFallback: true,
publicPath: '/',
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.ts', '.tsx', '.js', '.jsx'],
// we need this to reference files in the symlinked src/circuits directory
symlinks: false,
},
module: {
rules: [
{
test: /\.ts(x?)$/,
exclude: [
/node_modules/,
/snarkjs.min.js/
],
loader: 'ts-loader',
options: {
getCustomTransformers: () => ({
before: [styledComponentsTransformer],
}),
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}
]
},
{
test: /snarkjs.min.js/,
use: [
{
loader: 'file-loader',
}
]
},
{
test: /\.(js|jsx)$/,
exclude: [
/node_modules/,
/snarkjs.min.js/
],
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"]
}
}
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader',
},
],
},
plugins: [
new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [
{ from: 'public', to: '' }
]
}),
],
// When importing a module whose path matches one of the following, just
// assume a corresponding global variable exists and use that instead.
// This is important because it allows us to avoid bundling all of our
// dependencies, which allows browsers to cache those libraries between builds.
externals: {
},
};