forked from DimensionSoftware/instant-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
64 lines (58 loc) · 1.7 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
var nib = require('nib')
, path = require('path')
, webpack = require('webpack')
, ExtractText = require('extract-text-webpack-plugin');
var env = process.env.NODE_ENV || 'development'
, prod = env === 'production'
, domain = process.env.DOMAIN || process.env.npm_package_config_domain || 'develop.com'
, dev_port = process.env.npm_package_config_dev_port || 8081;
var entry =
{ client: ['./client/App' ] }
var plugins =
[ new webpack.optimize.DedupePlugin()
, new ExtractText('site.css', { allChunks:true })
]
var loaders =
[ { test: /\.styl$/, loader: ExtractText.extract('css-loader!stylus-loader') } ]
// init
// ----
if (prod) { // production settings
plugins.push(new webpack.optimize.UglifyJsPlugin())
loaders.push({ test: /\.ls$/, loader: 'livescript-loader?const=true' })
} else {
plugins.push(new webpack.HotModuleReplacementPlugin())
// add hot-reload
loaders.push({ test: /\.ls$/, loaders: ['react-hot', 'livescript-loader?const=true'] })
entry.client.push
('webpack/hot/dev-server'
, 'webpack-dev-server/client?http://'
+ domain
+ ':'
+ dev_port
)
}
// main
// ----
module.exports =
{ cache: !prod
, context: __dirname
, debug: !prod
, quiet: prod
, devtool: prod ? false : 'source-map'
, optimize: prod
, entry: entry
, plugins: plugins
, resolve: { extensions: ['', '.ls', '.js', '.styl'] }
, module: { loaders: loaders }
, stylus: { use: [nib()] }
, node: { fs: 'empty' }
, output:
{ path: path.join(__dirname, 'public/builds')
, filename: "[name].js"
, publicPath: 'http://'
+ domain
+ ':'
+ dev_port
+ '/builds/'
}
}