-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
72 lines (69 loc) · 2.13 KB
/
webpack.config.js
File metadata and controls
72 lines (69 loc) · 2.13 KB
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
const webpack = require('webpack')
const path = require('path');
const HtmlWebpackTemplate = require('html-webpack-template');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// Create some absolute paths for our configuration.
const paths = {
app : path.join(__dirname, 'app'),
build : path.join(__dirname, 'build')
};
// Export our config so webpack can pick it up.
module.exports = {
entry: {
// Here is where webpack will start going through files.
app : paths.app
},
output:{
// Here is where webpack will spit out the finished bundles and index.html.
path : paths.build,
// Call the finished product bundle.js
filename : 'bundle.js'
},
devtool: 'eval',
// Dev server settigns. Could also add directly to package.json script. ("build" : "webpack --inline --hot" ect..)
devServer: {
// Our dev server is hot( aka listening for change )
hot: true,
// Refresh on change.
inline: true,
stats: 'errors-only',
},
module : {
// Here is where the magic happens.
loaders : [
{
// A regular expression ( will pick up both .js and .jsx files )
test: /\.jsx?$/,
// When above file is encountered use this loader. babelrc contains the presets we want to use.
loader: 'babel-loader',
// Give webpack some direction. With out this it will search the etire directory.
include: paths.app
},
{
test: /\.css$/,
loaders: ['style-loader','css-loader'],
include: paths.app
},
{
test: /.*\.(png|jpe?g)$/i,
loader: 'file-loader',
include: paths.app
}
]
},
// Here are our plugins.
plugins : [
// Magical plugin that will live update changes in your code. This way we avod manually refreshing.
new webpack.HotModuleReplacementPlugin(),
// We are telling webpack to create a new html document and add our bundle as a script tag.
// (css as an link tag)
new HtmlWebpackPlugin({
// This is the template we want to use. You can have also create your own ejs template if you desire.
template: HtmlWebpackTemplate,
title: 'Uh Oh',
appMountId: 'app',
mobile: true,
inject: false,
})
]
}