-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
executable file
·94 lines (88 loc) · 2.27 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
/*
* Plugins
*/
var path = require('path');
var webpack = require('webpack');
// Webpack Plugins
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
var HandlebarsPlugin = require("handlebars-webpack-plugin");
/*
* Helpers
*/
var sliceArgs = Function.prototype.call.bind(Array.prototype.slice);
var toString = Function.prototype.call.bind(Object.prototype.toString);
/*
* Config
*/
module.exports = {
// for faster builds use 'eval'
devtool: 'source-map',
debug: true,
entry: {
'vendor': './src/vendor.js', // our vendors
'main': './src/index.js' // our application
},
// Config for our build files
output: {
path: './build/assets',
publicPath: './assets/',
filename: '[name].js',
sourceMapFilename: '[name].map',
chunkFilename: '[id].chunk.js'
},
module: {
loaders: [
// Javascript loader
{
test: /\.js$/,
exclude: /node_modules|backup/,
loader: 'babel-loader'
},
// Support for SCSS as sass
{
test: /\.scss$/,
loaders: ["style", "css?sourceMap", "sass?sourceMap"]
},
// support for .html as raw text
{
test: /\.html$/,
loader: 'raw-loader'
},
// support for fonts
{
test : /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader : 'file-loader'
},
// json loader
{
test: /\.json$/,
loader: 'json'
}
],
},
plugins: [
new CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.js', minChunks: Infinity }),
new CommonsChunkPlugin({ name: 'common', filename: 'common.js', minChunks: 2, chunks: ['main', 'vendor'] }),
new HandlebarsPlugin({
entry: "./src/index.hbs",
output: "./build/index.html",
data: require("./src/index.json"),
partials: [
"./src/partials/**/*.hbs"
]
}),
new webpack.ProvidePlugin({
'$': "jquery",
'jQuery': "jquery",
'Promise': 'imports?this=>global!exports?global.Promise!es6-promise',
'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
}),
new BrowserSyncPlugin({
open: false,
host: 'localhost',
port: 3000,
server: { baseDir: ['build'] }
})
]
};