forked from rwolke/thw-egs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.coffee
132 lines (119 loc) · 2.29 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
path = require "path"
webpack = require "webpack"
HtmlWebpackPlugin = require('html-webpack-plugin')
PROD = JSON.parse(process.env.PROD_ENV || '0');
plugins = []
plugins.push new webpack.ProvidePlugin
$: "jquery"
jquery: "jquery"
"windows.jQuery": "jquery"
"THREE": "THREE"
plugins.push new HtmlWebpackPlugin
filename: "index.html"
title: "EGS"
template: 'src/index.hbs'
if PROD
plugins.push new webpack.optimize.UglifyJsPlugin
compress:
warnings: false
#plugins.push new webpack.optimize.UglifyJsPlugin
module.exports =
# cache: false,
# debug: true
mode: if PROD then 'production' else 'development'
devtool: 'source-map'
entry:
app: "app"
lib: [
"jquery"
"THREE"
"three-orbit-controls"
]
output:
path: path.resolve(__dirname, 'dist')
filename: "js/[name].js"
# chunkFilename: "[id]_[name]_[hash].js"
externals:
google: 'google'
App: 'app',
window: 'window'
module:
rules: [
{
test: /\.(scss)$/
use: [
{
loader: 'style-loader'
}
{
loader: 'css-loader'
}
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: () => [
require('autoprefixer')
]
}
}
}
{
loader: 'sass-loader'
}
]
}
{
test: /\.coffee$/
use: [
{ loader: "coffee-loader" }
]
}
{
test: /\.hbs$/
use: [
{
loader: 'handlebars-loader'
options: {
inlineRequires: 'assets'
helperDirs: [__dirname + "/src/_helpers/handlebars"]
}
}
]
}
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
generator: {
filename: 'assets/[hash][ext][query]'
}
}
]
resolve:
modules: [
"node_modules",
"src",
"src/_helpers"
]
extensions: ["", ".js", ".coffee", ".hbs"]
resolveLoader:
modules: ["src/_loaders", "node_modules"]
extensions: ["", ".webpack-loader.js", ".web-loader.js", ".loader.js", ".js"]
mainFields: ["webpackLoader", "webLoader", "loader", "main"]
plugins: plugins
devServer:
headers:
"Access-Control-Allow-Origin": "*"
static: {
directory: path.join(__dirname, 'dist')
}
client: {
overlay: {
warnings: false,
errors: true
}
}
hot: 'only'
compress: true
port: 8080
# historyApiFallback: true