This repository has been archived by the owner on Jan 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.coffee
122 lines (108 loc) · 3.16 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
###
A generic webpack for building React components written in coffeescript and CJSX
jquery, react, react-dom, backbond and underscore are all external (not bundled)
See also, https://github.com/felixhao28/using-coffee-react-for-frontend-dev-walkthrough
###
fs = require('fs-extra')
_ = require('lodash')
Path = require("path")
Glob = require("glob")
Webpack = require("webpack")
Inflection = require('inflection')
StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin;
HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
# assume run from project root this the user of this package's package
userPackage = JSON.parse(fs.readFileSync('package.json'))
outputDir = Path.resolve(__dirname, 'dist/')
module.exports =
name: userPackage.name
entry: [
# "webpack-dev-server/client?http://localhost:3000", # WebpackDevServer host and port
# "webpack/hot/only-dev-server",
"./#{userPackage.main}" # Main app"s entry point according to package.json
],
output:{
path: outputDir
filename: "#{userPackage.name}.js"
libraryTarget: "umd"
library: Inflection.camelize(userPackage.name.replace(/[ \-]/g, "_"), false)
publicPath: "dist/"
},
resolveLoader: {
modules: [Path.resolve(__dirname, './node_modules')],
},
externals: {
'react': {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
}
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
}
'react-bootstrap': {
root: 'ReactBootstrap',
commonjs2: 'react-bootstrap',
commonjs: 'react-bootstrap',
amd: 'react-bootstrap'
}
'react-datum': {
root: 'ReactDatum',
commonjs2: 'react-datum',
commonjs: 'react-datum',
amd: 'react-datum'
}
'backbone': {
root: "Backbone"
commonjs2: 'backbone'
commonjs: 'backbone'
amd: 'backbone'
}
'underscore': {
root: "_"
commonjs2: 'underscore'
commonjs: 'underscore'
amd: 'underscore'
}
},
module: {
loaders: [{
test: /\.jsx?$/,
loaders: ['cache-loader', 'babel-loader'],
exclude: /node_modules/,
},{
test: /\.(coffee|cjsx)$/,
loaders: [
'coffee-loader'
'cjsx-loader',
]
},{
test: /\.(csv|txt|tpl)$/,
loader: 'raw-loader',
},{
#inline base64 encoded images, fonts
test: /\.(png|jpg|gif|woff|woff2|svg|ttf|eot)$/,
loader: 'url-loader'
}],
},
plugins: [
# // This plugin produces app/webroot/v7/webpackStats.json
# //
# // You can upload the file here to easily analyze the contents of the bundles:
# // https://chrisbateman.github.io/webpack-visualizer/
# //
# // Upload here: http://webpack.github.io/analyse/ to see the full dependency graph .
new StatsWriterPlugin({
filename: 'webpackStats.json',
fields: null,
transform: (data, opts) ->
stats = opts.compiler.getStats().toJson({chunkModules: true})
return JSON.stringify(stats, null, 2)
}),
# # for faster build
# new HardSourceWebpackPlugin(),
]