-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.coffee
101 lines (92 loc) · 2.63 KB
/
webpack.config.coffee
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
path = require "path"
webpack = require "webpack"
merge = require "webpack-merge"
notifier = require "node-notifier"
pkg = require "./package"
parts = require "./webpack.parts"
{ pathTo, assetHash } = parts
FriendlyErrorsWebpackPlugin = require "friendly-errors-webpack-plugin"
common_config = (env) -> merge [
target: "web"
context: pathTo("root")
resolve:
modules: [
pathTo("root")
pathTo("stylesheets")
"node_modules"
]
extensions: [".coffee", ".js", ".yml", ".json"]
alias:
icons: pathTo("icons")
images: pathTo("images")
modernizr$: ".modernizrrc"
masonry$: "masonry-layout/dist/masonry.pkgd.js"
isotope$: "isotope-layout"
gumshoe$: "gumshoe/dist/js/gumshoe.js"
"~susy": "susy/sass/susy"
"~scut": "scut/dist/scut"
"smooth-scroll": "smooth-scroll/dist/js/smooth-scroll.js"
"../img/loading.gif": "webui-popover/img/loading.gif"
entry:
main: [
"animate-css-webpack!./config/animate-css.js"
"./stylesheets"
"./index.coffee"
]
output:
chunkFilename: "javascripts/webpack_chunk_[id].js"
externals:
"jquery": "jQuery"
"$": "jQuery"
parts.loadCoffeeScript()
parts.loadJavaScript()
parts.loadSvgSprite()
parts.loadImage env
parts.loadModernizr()
]
module.exports = (env) ->
if env.target is "development"
return merge [
common_config env
plugins: [
new webpack.NamedModulesPlugin()
new webpack.LoaderOptionsPlugin { debug: on }
new FriendlyErrorsWebpackPlugin
onErrors: (severity, errors) ->
if severity isnt "error" then return
error = errors[0]
notifier.notify
title: error.name
subtitle: error.origin
message: error.webpackError.details
sound: "Sosumi"
]
parts.devServer()
parts.loadStylesheet()
]
return merge [
common_config env
entry:
vendor: [
"picturefill"
"lazysizes/plugins/rias/ls.rias"
"lazysizes/plugins/bgset/ls.bgset"
"lazysizes"
"waypoints/lib/jquery.waypoints"
"webui-popover/dist/jquery.webui-popover.js"
"chosen-js"
"slick-carousel"
]
output:
path: path.resolve __dirname, env.build_path
publicPath: pkg.publicPath
filename: "javascripts/webpack_[name].js"
plugins: [
new webpack.DefinePlugin
"process.env":
"NODE_ENV": JSON.stringify "production"
new webpack.NoEmitOnErrorsPlugin()
]
parts.extractBundles [{name: "vendor"}]
parts.extractStylesheet env
]