This repository has been archived by the owner on Apr 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
112 lines (102 loc) · 2.2 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
/**
* External dependencies
*/
var webpack = require( 'webpack' ),
autoprefixer = require( 'autoprefixer' ),
NODE_ENV = process.env.NODE_ENV || 'development',
path = require( 'path' );
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
var config = {
mode: NODE_ENV,
entry: {
'bundle' : [
'./src'
]
},
output: {
path: path.join( __dirname, 'build' ),
publicPath: '/build/',
filename: '[name].js',
devtoolModuleFilenameTemplate: 'app:///[resource-path]'
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
include: path.join( __dirname, '/src' )
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.scss$/,
loaders: [
'isomorphic-style-loader',
'css-loader?modules&importLoaders=1&localIdentName=[path][local]&camelCase=dashes&sourceMap',
'postcss-loader',
'sass-loader?sourceMap'
]
}
],
},
resolve: {
extensions: [ '.json', '.js', '.jsx' ]
},
node: {
console: false,
process: true,
global: true,
Buffer: true,
__filename: 'mock',
__dirname: 'mock',
fs: 'empty'
},
plugins: [
new webpack.DefinePlugin( {
'process.env': {
NODE_ENV: JSON.stringify( NODE_ENV ),
BROWSER: JSON.stringify( true )
}
} ),
]
};
if ( process.env.NODE_ENV !== 'production' ) {
// Switches loaders to debug mode. This is required to make CSS hot reloading works correctly (see
// http://bit.ly/1VTOHrK for more information).
//config.debug = true;
// Enables source maps
config.devtool = 'eval';
config.devServer = {
hot: true,
port: 7777,
historyApiFallback: true
};
/*config.module.rules.unshift( {
test: /\.jsx?$/,
loader: 'react-hot-loader/webpack',
include: path.join( __dirname, '/src' ),
exclude: /node_modules/,
} );*/
}
if ( NODE_ENV === 'production' ) {
config.optimization = {};
config.optimization.minimizer = [
new UglifyJsPlugin()
];
/*config.plugins.push(
new webpack.optimize.UglifyJsPlugin( {
output: {
comments: false
},
compress: {
warnings: false
}
} )
);*/
}
module.exports = config;