-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
89 lines (83 loc) · 2.47 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
"use strict";
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require("webpack");
const path = require("path");
const merge = require('webpack-merge');
const PATHS = {
app: path.join(__dirname, 'examples/es6/src/main.jsx'),
build: path.join(__dirname, 'examples/es6/public/')
};
const common = {
entry: PATHS.app,
devtool: 'source-map',
output: {
filename: 'resources/bundle.js',
path: PATHS.build,
sourceMapFilename: 'resources/[file].map'
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015'] //Babel transformation usually on .babelrc
}
},
{
test: /\.scss$/,
loaders: ["style", "css", "sass?includePaths[]="+ path.resolve(__dirname, 'app/src/styles/')]
},
{
test: /\.css$/,
loaders: ["style", "css"]
},
]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
'plugins':[
new HtmlWebpackPlugin({
template: 'examples/es6/src/index.tpl.html',
inject: 'body',
filename: 'index.html'
})
]
}
const TARGET = process.env.npm_lifecycle_event;
if(TARGET === 'example:es6' || !TARGET) {
let config = {
//Data that dev server will consume
devServer: {
contentBase: PATHS.build,
// Enable history API fallback so HTML5 History API based
// routing works. This is a good default that will come
// in handy in more complicated setups.
historyApiFallback: true,
hot: true,
inline: true,
progress: true,
// Display only errors to reduce the amount of output.
stats: 'errors-only',
// Parse host and port from env so this is easy to customize.
//
// If you use Vagrant or Cloud9, set
// host: process.env.HOST || '0.0.0.0';
//
// 0.0.0.0 is available to all network devices unlike default
// localhost
host: process.env.HOST || '0.0.0.0',
port: process.env.PORT || '8080'
},
'plugins':[
new webpack.HotModuleReplacementPlugin()
]
};
module.exports = merge(common, config);
}
else if(TARGET === 'build') {
module.exports = common;
}