/
webpack.config.js
196 lines (193 loc) · 6.64 KB
/
webpack.config.js
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
const webpack = require('webpack');
const path = require("path");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const CompressionPlugin = require("compression-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const prod = process.argv.indexOf('-p') !== -1;
module.exports = {
context: __dirname,
entry: {
application: 'application.js'
},
resolve: {
modules: [
'assets',
'node_modules'
],
extensions: ['.ts', '.tsx', '.js'],
alias: {
requireLib: 'require',
markdown: require.resolve('markdown/lib/markdown.js')
}
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules|vendor/
},
{
test: /\.js$/, // include .js files
exclude: /node_modules/, // exclude any and all files in the node_modules folder
loader: 'eslint-loader'
},
{
test: /bootstrap/,
use: {
loader: 'imports-loader',
options: {'jQuery': 'jquery'}
}
},
{
test: /Jcrop/,
use: {
loader: 'imports-loader',
options: {'jQuery': 'jquery'}
}
},
{
test: /tagsinput/,
use: {
loader: 'imports-loader',
options: {'window.jQuery': 'jquery'}
}
},
{
test: /.html$/,
use: {
loader: "html-loader"
}
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
/*{
test: /\.less$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader!less-loader"
})
},*/
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
},
//{test: /\.(jpe?g|png|gif|svg)$/i, loader: "file-loader?name=img/[name].[ext]"},
{
test: /\.(jpe?g|png|gif|svg)$/i,
use: [
{
loader: 'url-loader',
options: {
prefix: 'img/',
limit: 10000,
hash: 'sha512',
digest: 'hex',
name: 'img/[hash].[ext]'
}
},
{
loader: 'image-webpack-loader',
options: {
optipng: {
optimizationLevel: 5,
},
gifsicle: {
interlaced: false
}
}
}
]
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: {
loader: "url-loader",
options: {
name: 'fonts/[hash].[ext]',
limit: 10000,
mimetype: 'application/font-woff'
}
}
},
{
test: /fontawesome-webfont\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: {
loader: "file-loader",
options: {
name: 'fonts/[hash].[ext]'
}
}
},
{
test: /glyphicons-halflings-regular\.(ttf|eot|svg)$/,
use: {
loader: "file-loader",
options: {
name: 'fonts/[hash].[ext]'
}
}
}
]
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "css/[name].[hash].css",
chunkFilename: 'css/[id].[hash].css',
}),
new ManifestPlugin(),
//new webpack.optimize.CommonsChunkPlugin("vendor", "js/vendor.bundle.js"), //.[chunkhash]
new HtmlWebpackPlugin(),
new FaviconsWebpackPlugin({ // Your source logo
logo: __dirname + '/module/Application/assets/logo-bg.svg',
// The prefix for all image files (might be a folder or a name)
prefix: 'icons-[hash]/',
// Emit all stats of the generated icons
emitStats: true,
// The name of the json containing all favicon information
statsFilename: 'iconstats.json',
// Generate a cache file with control hashes and
// don't rebuild the favicons until those hashes change
persistentCache: true,
// Inject the html into the html-webpack-plugin
inject: true,
// favicon background color (see https://github.com/haydenbleasel/favicons#usage)
background: '#ede9de',
// favicon app title (see https://github.com/haydenbleasel/favicons#usage)
title: 'WheelsAge.org',
// which icons should be generated (see https://github.com/haydenbleasel/favicons#usage)
icons: {
android: true,
appleIcon: true,
appleStartup: true,
coast: true,
favicons: true,
firefox: true,
opengraph: true,
twitter: true,
yandex: true,
windows: true
}
}),
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en|ru|be|zh-cn|fr|pt-br|uk|es|it|he/)
].concat(prod ? [
new CompressionPlugin({
filename: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.svg$|\.eot$|\.woff2?$|\.ttf$/,
threshold: 10240,
minRatio: 0.8
})
] : []),
output: {
path: path.join(__dirname, "public_html/dist"),
filename: "js/[name].[chunkhash].js",
publicPath: "/dist/"
}
}