forked from littlebee/bumble-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.coffee
162 lines (148 loc) · 4.71 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
###
Unoptimized config makes dist/react-datum.js
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')
# assume run from project root this the user of this package's package
userPackage = JSON.parse(fs.readFileSync('package.json'))
# node.js will not allow us to require something from the user app's dir, so
# copy it to our root. So the user can optionally provide overrides for
# this type of webpack config
for confFile in Glob.sync('./webpack.*', nodir: true)
# console.log "copying #{confFile} to node_modules/bumble-test"
fs.copySync(confFile, Path.join("node_modules/bumble-build/", "__#{Path.basename(confFile)}"))
requireFile = './__webpack.config'
configFile = Path.join("node_modules/bumble-build/", '__webpack.config')
userConfig = if fs.existsSync(configFile + '.js') || fs.existsSync(configFile + '.coffee')
test = require(requireFile)
else
{}
module.exports = _.defaultsDeep userConfig,
cache: true
entry: [
# "webpack-dev-server/client?http://localhost:3000", # WebpackDevServer host and port
# "webpack/hot/only-dev-server",
"./#{userPackage.main}" # Main app"s entry point
],
output:
path: "dist/"
filename: "#{userPackage.name}.js"
libraryTarget: "umd"
library: Inflection.camelize(userPackage.name.replace(/[ \-]/g, "_"), false)
publicPath: "dist/"
externals: [
{
'jquery': {
root: 'jQuery'
commonjs2: 'jquery',
commonjs: 'jquery',
amd: 'jquery'
}
},{
'react': {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
}
},{
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
}
},{
'backbone': {
root: "Backbone"
commonjs2: 'backbone'
commonjs: 'backbone'
amd: 'backbone'
}
},{
'underscore': {
root: "_"
commonjs2: 'underscore'
commonjs: 'underscore'
amd: 'underscore'
}
}
]
debug: true,
resolve:
extensions: ["", ".jsx", ".cjsx", ".coffee", ".js"]
modulesDirectories: ["src", "node_modules"]
module:
loaders: [
#
# DON'T USE THIS if you do a require(`../css/someFile.css`) that file will fail to load in tests
# If you need to include CSS for a component of this lib:
# - keep it minimal (let our users style and format)
# - please don't use inline styles as they are difficult for our user to override
# - put the css in a file that is of same or similar name to the components in the css/ dir
#
# test: /\.css$/ # required to write "require("./someFile.css")"
# loader: "style-loader!css-loader"
# ,
# required for bootstrap icons
test: /\.(woff|woff2)$/
loader: "url-loader?prefix=font/&limit=5000&mimetype=application/font-woff"
,
test: /\.ttf$/
loader: "file-loader?prefix=font/"
,
test: /\.eot$/
loader: "file-loader?prefix=font/"
,
test: /\.svg$/
loader: "file-loader?prefix=font/"
,
test: require.resolve("jquery")
loader: "expose?$"
,
test: require.resolve("jquery")
loader: "expose?jQuery"
,
# test: require.resolve("react")
# loader: "expose?React"
# ,
# test: /\.jsx$/
# loaders: ["react-hot", "jsx-loader?insertPragma=React.DOM"]
# include: Path.join(__dirname, "src")
# ,
test: /\.cjsx$/
loaders: ['coffee', 'cjsx']
,
test: /\.coffee$/
loader: 'coffee-loader'
,
test: /\.jsx?$/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
,
test: /\.(png|jpg|gif)$/
loader: 'url-loader?limit=8192' # inline base64 URLs for <=8k images, direct URLs for the rest
#test: /\.jpe?g$|\.gif$|\.png|\.ico$/, loader: 'file'
,
test: /\.json$/
loader: 'json'
]
plugins: [
# # this adds a lot of code to the bundle for hot loading feature
# new Webpack.HotModuleReplacementPlugin()
## I think this and changing the debug setting above to `debug: false` above are all that
## should be needed to produce an optimized minified package
# new Webpack.optimize.DedupePlugin(),
# new Webpack.optimize.UglifyJsPlugin
# compress:
# warnings: false
# mangle:
# except: ['$super', '$', 'exports', 'require']
]