-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
124 lines (119 loc) · 2.97 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
113
114
115
116
117
118
119
120
121
122
123
124
/* global __dirname */
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const Dotenv = require('dotenv-webpack');
var plugins = [
new ExtractTextPlugin('app.css', {
allChunks: true,
}),
new HtmlWebpackPlugin({
template: 'app/templates/index.html'
}),
new HtmlWebpackExternalsPlugin({
externals: [
{
module: 'ZAFClient',
entry: 'https://assets.zendesk.com/apps/sdk/2.0/zaf_sdk.js',
global: 'ZAFClient',
},
]
}),
new Dotenv(),
];
module.exports = (env) => {
const isProduction = env && !!env.production;
return {
mode: isProduction ? 'production' : 'development',
entry: path.resolve(path.resolve(__dirname, 'src'), 'app.js'),
output: {
path: path.resolve(__dirname, 'app/assets'),
filename: 'bundle.js'
},
optimization: {
minimize: true,
mergeDuplicateChunks: true,
concatenateModules: true
},
plugins: plugins,
module: {
rules: [
{
test: /\.mp3$/,
loader: 'file-loader'
},
{
test: [
/\.bmp$/,
/\.gif$/,
/\.jpe?g$/,
/\.png$/,
/\.svg$/,
/\.woff$/,
/\.woff2$/,
/\.eot$/,
/\.ttf$/,
],
loader: require.resolve('url-loader'),
options: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]',
},
},
{
test: /\.(js|jsx|mjs)$/,
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: true,
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: [
[ '@babel/plugin-proposal-decorators', { 'legacy': true } ],
[ '@babel/plugin-proposal-class-properties', { 'loose': true } ]
]
}
}
]
},
{
test: /\.css$/,
use: [ 'css-loader' ]
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
modules: true,
sourceMap: false,
importLoaders: 2,
localIdentName: `[local]___[hash:base64:5]`
}
},
'sass-loader'
]
})
}
]
},
stats: {
colors: true
},
node: {
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty',
},
performance: {
hints: false,
},
};
};