This repository has been archived by the owner on Apr 4, 2022. It is now read-only.
/
webpack.config.coffee
95 lines (72 loc) · 1.86 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
# Webpack 4 is "zero configuration", so here's our Webpack
# configuration. It's zero! Really!
CleanWebpackPlugin = require "clean-webpack-plugin"
path = require "path"
webpack = require "webpack"
MiniCssExtractPlugin = require "mini-css-extract-plugin"
ZopfliPlugin = require "zopfli-webpack-plugin"
# Set up our module rules.
rules = (env, argv) ->
r = []
r.push
test: /\.vue$/
loader: "vue-loader"
r.push
test: /\.coffee$/
use: "coffee-loader"
r.push
test: /\.(s?)css$/
use: [
"css-hot-loader"
MiniCssExtractPlugin.loader
"css-loader"
"sass-loader"
]
r
# Aaaaaand a bunch of plugins.
plugins = (env, argv) ->
p = []
p.push new CleanWebpackPlugin ["public/assets"]
p.push new MiniCssExtractPlugin
filename: "[name].css"
chunkFilename: "[id].css"
if argv.mode == "production"
p.push new ZopfliPlugin
asset: "[path].gz"
algorithm: "zopfli"
minRatio: 0
else # development
p.push new webpack.NamedModulesPlugin
p.push new webpack.HotModuleReplacementPlugin
p
# Here's the Webpack configuration itself.
module.exports = (env, argv) ->
entry:
blog: "./web/blog/index.coffee"
app: "./web/app/index.coffee"
output:
path: __dirname + "/public/assets"
filename: "[name]-bundle.js"
publicPath: "http://localhost:8080/assets"
module:
rules: rules(env, argv)
resolve:
extensions: ["*", ".js", ".coffee", ".vue"]
alias:
"@": path.resolve __dirname, "web/app"
plugins: plugins(env, argv)
devServer:
inline: true
hot: true
public: "localhost:8080"
contentBase: __dirname + "/public/assets"
headers: { "Access-Control-Allow-Origin": "*" }
overlay:
warnings: true
errors: true
watchOptions:
ignored: /node_modules/
stats:
colors: true
watchOptions:
ignored: /node_modules/