-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
111 lines (91 loc) · 3.1 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'),
path = require('path'),
ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = [
{
// Compiler ID
name: 'desktop',
// Makes sure errors in console map to the correct file and line number
devtool: 'eval-source-map',
// Define entry points
entry: {
// App entry point
app: [
// For hot style updates
'webpack/hot/dev-server',
// The script refreshing the browser on none hot updates
'webpack-dev-server/client?http://localhost:8080',
// Main app
path.resolve(__dirname, 'app', 'index.jsx')
],
// Common vendor packages
vendor: [
'underscore',
'react/addons',
'flummox'
]
},
// Set modules output
output: {
path: path.resolve(__dirname, 'public', 'dist'),
publicPath: '/dist/',
filename: 'bundle.js'
},
// Define module loaders
module: {
loaders: [
{ // ES6 Loader
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel?optional[]=runtime'
},
{ // JSON Loader
test: /\.json$/,
loader: 'json'
},
{ // JADE Loader
test: /\.jade$/,
loader: 'jade'
},
{ // CSS Loader
test: /\.css$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader")
},
{ // LESS Loader
test: /\.less$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader!less-loader")
},
{ // SASS Loader
test: /\.scss$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader!sass-loader")
}
]
},
// Setting up resolution
resolve: {
modulesDirectories: [
'node_modules',
'resources',
'app'
],
extensions: ['', '.js', '.jsx']
},
// Set up plugins
plugins: [
// Define module globals
new webpack.ProvidePlugin({
'_': 'underscore',
'React': 'react',
'Component': 'flummox/component'
}),
// Deduplication
new webpack.optimize.DedupePlugin(),
// Chunk out vendor code
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'),
// Extract CSS files
new ExtractTextPlugin("styles.css"),
// Hot module replacement
new webpack.HotModuleReplacementPlugin()
]
}
];