-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
111 lines (89 loc) · 2.67 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
var Webpack = require('webpack');
var path = require('path');
var nodeModulesPath = path.resolve(__dirname, 'node_modules');
var buildPath = path.resolve(__dirname, 'public', 'build');
var mainPath = path.resolve(__dirname, 'app', 'main.js');
var env = process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var Promise = require('es6-promise').Promise;
var config = {
// Makes sure errors in console map to the correct file
// and line number
//devtool: 'eval',
devtool: 'source-map',
entry: [
// For hot style updates
'webpack/hot/dev-server',
// The script refreshing the browser on none hot updates
'webpack-dev-server/client?http://localhost:8080',
// Our application
mainPath
//,'file?name=index.html!jade-html!./public/index.jade'
],
output: {
// We need to give Webpack a path. It does not actually need it,
// because files are kept in memory in webpack-dev-server, but an
// error will occur if nothing is specified. We use the buildPath
// as that points to where the files will eventually be bundled
// in production
path: buildPath,
filename: 'bundle.js',
// Everything related to Webpack should go through a build path,
// localhost:3000/build. That makes proxying easier to handle
publicPath: '/build/'
},
externals: [
{
"window": "window"
}
],
module: {
loaders: [
// I highly recommend using the babel-loader as it gives you
// ES6/7 syntax and JSX transpiling out of the box
// Let us also add the style-loader and css-loader, which you can
// expand with less-loader etc.
{
test: /\.css$/,
loader: 'style!css'
},
{
test: /\.styl$/,
resolveLoader: { fallback: path.join(__dirname, "node_modules") },
loader: 'style!css!stylus'
},
{
test: /\.js$/,
loaders: ['ng-annotate', 'babel-loader' ],
exclude: [nodeModulesPath]
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
loader: 'url-loader?limit=100000'
},
{
test: /\.jade$/,
loader: "jade-loader"
},
{
test: /\.node$/,
loader: "node-loader"
}
]
},
// We have to manually add the Hot Replacement plugin when running
// from Node
plugins: [new Webpack.HotModuleReplacementPlugin(),
new Webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
],
// This sets up config based on environment
resolve: {
alias: {
config: path.join(__dirname, '/app/config', env)
},
extensions: ['', '.js', '.node']
}
};
module.exports = config;