-
Notifications
You must be signed in to change notification settings - Fork 19
/
webpack.prod.config.js
112 lines (99 loc) · 2.68 KB
/
webpack.prod.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 CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const TerserPlugin = require('terser-webpack-plugin');
const merge = require('webpack-merge');
const webpack = require('webpack');
const baseConfig = require('./webpack.base.config.js');
const config = merge(baseConfig, {
mode: 'production',
devtool: 'cheap-source-map',
entry: {
// the entry point of our app
app: __dirname + '/src/index.tsx',
},
output: {
filename: "[name].bundle-[hash:8].js",
chunkFilename: '[id].chunk-[hash:8].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
optimization: {
minimize: true,
minimizer: [
new OptimizeCSSAssetsPlugin({}),
new TerserPlugin({
terserOptions: {
}
})
],
splitChunks: {
chunks: 'all',
}
},
module: {
rules: [
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
modules: {
localIdentName: "[name]--[local]--[hash:base64:5]"
},
importLoaders: 2
}
},
'sass-loader',
{
loader: 'sass-resources-loader',
options: {
resources: ['./src/assets/styles/global-variables.scss']
}
}
],
},
],
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "[name].[hash].css",
chunkFilename: "[id].[hash].css",
modules: true
}),
new webpack.EnvironmentPlugin({
NETWORKS: "main",
NODE_ENV: "production",
SHOW_ALL_DAOS: "false",
BASE_URL: "https://alchemy.daostack.io",
DISQUS_SITE: 'daostack-alchemy',
ARC_GRAPHQLHTTPPROVIDER: "",
ARC_GRAPHQLWSPROVIDER : "",
ARC_WEB3PROVIDER : "",
ARC_WEB3PROVIDERREAD : "",
ARC_IPFSPROVIDER: "",
ARC_IPFSPROVIDER_HOST : "",
ARC_IPFSPROVIDER_PORT : "",
ARC_IPFSPROVIDER_PROTOCOL : "",
ARC_IPFSPROVIDER_API_PATH : "",
INFURA_ID : "",
ETHERSCAN_API_KEY : "",
MIXPANEL_TOKEN: "",
}),
new CopyWebpackPlugin([
{ from: 'src/assets', to: 'assets' }
]),
],
});
if (process.env.ANALYZE) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'static',
}));
}
module.exports = config;