forked from dinobi/Bootcamp-LOS-24-POSTIT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.production.js
108 lines (105 loc) · 2.98 KB
/
webpack.config.production.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
const path = require('path');
const webpack = require('webpack');
const port = process.env.PORT || 3001;
const outputPath = `${__dirname}/client/dist`;
module.exports = {
devtool: 'source-map',
entry: './client/src/app/index.jsx',
output: {
path: outputPath,
filename: 'bundle.min.js',
publicPath: '/dist/'
},
resolve: {
modules: ['node_modules', './client/src'],
extensions: ['.js', '.jsx'],
},
module: {
loaders: [
// ** ADDING/UPDATING LOADERS **
// The "file" loader handles all assets unless explicitly excluded.
// The `exclude` list *must* be updated with every change
// to loader extensions.
// When adding a new loader, you must add its `test`
// as a new entry in the `exclude` list for "file" loader.
// "file" loader makes sure those assets get served by WebpackDevServer.
// When you `import` an asset, you get its (virtual) filename.
// In production, they would get copied to the `build` folder.
{
exclude: [
/\.html$/,
/\.(js|jsx)$/,
/\.css$/,
/\.scss$/,
/\.sass$/,
/\.json$/,
/\.bmp$/,
/\.gif$/,
/\.jpe?g$/,
/\.png$/,
],
loader: require.resolve('file-loader'),
options: {
name: 'bundle.[ext]',
},
},
// "url" loader works like "file" loader except that it embeds assets
// smaller than specified limit in bytes as data URLs to avoid requests.
// A missing `test` is equivalent to a match.
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
loader: require.resolve('url-loader'),
options: {
limit: 10000,
name: 'bundle.[ext]',
},
},
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.scss/,
loader: 'style-loader!css-loader!sass-loader'
},
{ test: /\.css$/,
loaders: [
'style-loader',
'css-loader?importLoaders=1',
]
},
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
minimize: true,
sourceMap: true,
compress: {
screw_ie8: true,
warnings: false
},
output: {
comments: false,
screw_ie8: true
},
}),
new webpack.EnvironmentPlugin({ NODE_ENV: 'production' }),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'production'),
APP_URL: JSON.stringify(process.env.APP_URL),
JWT_EXPIRY_TIME: JSON.stringify(process.env.JWT_EXPIRY_TIME),
}
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Hammer: 'hammerjs/hammer'
}),
// Add module names to factory functions so they appear in browser profiler.
new webpack.NamedModulesPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
],
};