-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.production.config.js
62 lines (61 loc) · 1.72 KB
/
webpack.production.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
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const StyleExtHtmlWebpackPlugin = require('style-ext-html-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const config = require('./env.config.js').production;
module.exports = {
devtool: '#cheap-module-eval-source-map',
context: path.resolve(__dirname, 'src'),
entry: [
'./js/index.js',
'./styles/main.scss'
],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
resolve: {
extensions: ['.js'],
modules: ['node_modules']
},
module: {
rules: [
{
test: /\.js?$/,
exclude: /node_modules/,
use: 'babel-loader?presets[]=es2015'
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader']
})
},
{
test: /\.(jpe?g|gif|png|svg|woff|ttf|wav|mp3)$/,
loader: 'file-loader',
options: {
name: '[path][name]-[hash].[ext]'
}
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production'),
'PUSHER_KEY': JSON.stringify(config.PUSHER_KEY),
'SERVER_URL': JSON.stringify(config.SERVER_URL),
'CHANNEL_NAME': JSON.stringify(config.CHANNEL_NAME)
}
}),
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({ template: './index.html' }),
new ExtractTextPlugin('styles.css'),
new StyleExtHtmlWebpackPlugin(),
new webpack.optimize.UglifyJsPlugin({ output: { ascii_only: true } })
],
};