-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.config.js
98 lines (88 loc) · 2.28 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
require('dotenv').config();
const webpack = require('webpack');
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const prodPlugins =
[ new webpack.EnvironmentPlugin(['CLIENT_ID', 'CLIENT_SECRET', 'REDIRECT_URI']),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true
},
mangle: true
}),
new CopyWebpackPlugin([
{ from: 'src/auth.html', to: 'auth.html' },
{ from: 'src/style.css', to: 'dist/style.css' },
{ from: 'vendor/', to: 'dist/vendor/'}
])
]
const devPlugins = [
new webpack.EnvironmentPlugin(['CLIENT_ID', 'CLIENT_SECRET', 'REDIRECT_URI']),
new CopyWebpackPlugin([
{ from: 'src/auth.html', to: 'auth.html' },
{ from: 'src/style.css', to: 'dist/style.css' },
{ from: 'vendor/', to: 'dist/vendor/'}
])
]
const plugins =
process.env.BUILD_TO === 'production'
? prodPlugins
: devPlugins
const elmLoaderProdConfig = 'elm-webpack-loader'
const elmLoaderDevConfig = 'elm-webpack-loader?verbose=true&warn=true&debug=true'
module.exports = {
entry: {
app: [
'./src/index.js'
],
},
output: {
path: path.resolve(__dirname + '/dist'),
filename: '[name].js',
},
module: {
rules: [
{
test: /\.html$/,
exclude: /node_modules/,
loader: 'file-loader?name=[name].[ext]',
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
},
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/, /Stylesheets\.elm$/],
loader: process.env.BUILD_TO === 'production' ? elmLoaderProdConfig : elmLoaderDevConfig
},
{
test: /Stylesheets\.elm$/,
use: [
'style-loader',
'css-loader',
'elm-css-webpack-loader'
]
}
],
},
plugins: plugins,
devServer: {
inline: true,
stats: { colors: true },
},
}