-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
59 lines (55 loc) · 1.55 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
const webpack = require('webpack');
const path = require('path');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const HtmlWebpackPlugin = require('html-webpack-plugin')
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const ENV = process.env.npm_lifecycle_event;
const isProd = ( ENV === 'dist' || ENV === 'dist:serve' );
var config = {
entry: "./src/app.js",
output: {
path: __dirname + '/public',
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.js$/,
loader: "babel",
query: {
presets: ['es2015']
},
exclude: /node_modules/
},
{ test: /\.scss$/, loader: "style-loader!css-loader!postcss-loader!sass-loader", exclude: /node_modules/ },
{ test: /\.css$/, loader: "style-loader!css-loader!postcss-loader", exclude: /node_modules/ },
{ test: /\.html$/, loader: 'html-loader', exclude: /node_modules/ }
]
},
node: {
fs: "empty"
},
postcss: function() {
return [precss, autoprefixer];
},
plugins: [
new BrowserSyncPlugin({
// browse to http://localhost:3000/ during development,
// ./public directory is being served
host: 'localhost',
port: 3000,
server: { baseDir: ['public'] }
}),
new HtmlWebpackPlugin({
template: 'src/index.html',
title: 'Hotels Search App'
})
]
};
if(isProd) {
config.plugins.push(
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
);
}
module.exports = config;