forked from daostack/alchemy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.config.js
126 lines (113 loc) · 3.17 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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 WebpackShellPlugin = require('webpack-shell-plugin');
const baseConfig = require('./webpack.base.config.js');
const config = merge(baseConfig, {
mode: 'production',
devtool: 'source-map',
entry: {
// the entry point of our app
app: __dirname + '/src/index.tsx',
// 'ipfs-http-client': ['ipfs-http-client'],
// '@daostack/migration': ['@daostack/migration/']
},
output: {
filename: "[name].bundle-[hash:8].js",
chunkFilename: '[name].bundle-[hash:8].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
optimization: {
minimize: true,
minimizer: [
new OptimizeCSSAssetsPlugin({}),
new TerserPlugin({
terserOptions: {
}
})
],
splitChunks: {
chunks: 'all',
cacheGroups: {
// "ipfs-http-client": {
// chunks: "initial",
// test: "ipfs-http-client",
// name: "ipfs-http-client",
// enforce: true
// },
// "@daostack/migration": {
// chunks: "initial",
// test: "@daostack/migration",
// name: "@daostack/migration",
// enforce: true
// }
}
}
},
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({
NETWORK: "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 : "",
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());
}
module.exports = config;