-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.config.js
98 lines (93 loc) · 2.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
'use strict';
var path = require('path');
var webpack = require('webpack');
var combineLoaders = require('webpack-combine-loaders');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
function envVars() {
let vars = [
'REACT_APP_API_KEY',
'REACT_APP_APP_ID',
'REACT_APP_AUTH_DOMAIN',
'REACT_APP_PROJECT_ID',
'REACT_APP_STORAGE_BUCKET',
'REACT_APP_DB_URL',
'REACT_APP_SENDER_ID',
'REACT_APP_MEASUREMENT_ID'
]
return vars.reduce((obj, v) => {
const keyname = `process.env.${v}`
return {
...obj,
[keyname]: JSON.stringify(process.env[v])
}
}, {})
}
module.exports = {
devtool: 'source-map',
context: path.join(__dirname),
mode: 'production',
entry: {
vendor: [
'@babel/polyfill'
],
main: [
path.join(__dirname, 'src/client/main.tsx')
],
},
output: {
path: path.join(__dirname, 'src/assets/public/js'),
filename: '[name].js',
publicPath: '/src/assets/public/'
},
plugins:[
new webpack.NamedModulesPlugin(),
new ForkTsCheckerWebpackPlugin({
// Maximum for CircleCI Free
workers: 2,
tsconfig: path.join(__dirname, 'src/client/tsconfig.json')
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
...envVars()
}),
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery',
jquery: 'jquery'
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new ExtractTextPlugin({
filename: 'styles.css',
allChunks: true
})
],
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
alias: {
'~': path.join(__dirname, '/src/client'),
'@Shared': path.join(__dirname, '/src/shared')
}
},
module: {
rules: [{
test: /\.(j|t)s?(x)?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true
}
},
}, {
test: /\.json?$/,
loader: 'json-loader'
}, {
test: /\.css$/,
loader: 'style-loader!css-loader'
}]
}
};