forked from daostack/alchemy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.config.js
111 lines (100 loc) · 2.92 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
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 UglifyJsPlugin = require('uglifyjs-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: 'nosources-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",
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
},
optimization: {
minimize: true,
minimizer: [
new OptimizeCSSAssetsPlugin({}),
new UglifyJsPlugin({uglifyOptions: {
compress: true
}
})
],
splitChunks: {
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.DefinePlugin({
'process.env': {
'API_URL': JSON.stringify(process.env.API_URL || "https://daostack-alchemy.herokuapp.com"),
'BASE_URL': JSON.stringify(process.env.BASE_URL || "https://alchemy.daostack.io"),
'DISQUS_SITE': JSON.stringify(process.env.DISQUS_SITE || 'daostack-alchemy'),
'NODE_ENV': JSON.stringify(process.env.NODE_ENV) || JSON.stringify("production")
},
}),
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;