-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.coffee
74 lines (61 loc) · 1.62 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
path = require 'path'
webpack = require 'webpack'
nodeExternals = require 'webpack-node-externals'
BuildEnvironment = process.env.NODE_ENV or 'development'
if BuildEnvironment not in ['development', 'production']
throw new Error "Undefined environment #{BuildEnvironment}"
# set output filenames
WebPackOutputFilename =
development: 'backbone.themoviedb.js'
production: 'backbone.themoviedb.min.js'
# path to build directory
localBuildDir =
development: "dist"
production: "dist"
WebPackOutput =
filename: WebPackOutputFilename[BuildEnvironment]
#path: path.resolve 'build'
library: 'Backbone.Themoviedb'
libraryTarget: 'umd'
coffeeLoaderRule =
test: /\.coffee$/
loader: 'coffee-loader'
options:
transpile:
presets: ['env']
sourceMap: true
common_plugins = []
extraPlugins = []
WebPackOptimization = {}
if BuildEnvironment is 'production'
UglifyJsPlugin = require 'uglifyjs-webpack-plugin'
WebPackOptimization.minimizer = [
new UglifyJsPlugin
sourceMap: true
uglifyOptions:
warnings: true
]
AllPlugins = common_plugins.concat extraPlugins
WebPackConfig =
mode: BuildEnvironment
optimization: WebPackOptimization
entry:
app: ['./src/index.coffee']
output: WebPackOutput
plugins: AllPlugins
externals: [nodeExternals()]
module:
rules: [
coffeeLoaderRule
]
resolve:
extensions: [".wasm", ".mjs", ".js", ".json", ".coffee"]
stats:
colors: true
modules: false
chunks: true
#maxModules: 9999
#reasons: true
if BuildEnvironment is 'development'
WebPackConfig.devtool = 'source-map'
module.exports = WebPackConfig