-
Notifications
You must be signed in to change notification settings - Fork 365
Expand file tree
/
Copy pathwebpack.config.mjs
More file actions
64 lines (61 loc) · 2.01 KB
/
Copy pathwebpack.config.mjs
File metadata and controls
64 lines (61 loc) · 2.01 KB
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
import path from 'path'
import TerserPlugin from 'terser-webpack-plugin'
import WebpackCustomUMD from './webpack.custom-umd.mjs'
import webpack from 'webpack'
import { readFileSync } from 'fs'
// Read package.json
const pkg = JSON.parse(readFileSync(path.resolve(import.meta.dirname, 'package.json'), 'utf-8'))
// Generate banner comment with version and build date
const banner = `/*!
* jQuery Mockjax v${pkg.version} - https://github.com/jakerella/jquery-mockjax
* Build Date: ${new Date().toISOString().split('T')[0]}
* Copyright (c) ${new Date().getFullYear()} Jordan Kasper and contributors, formerly appendTo
* Licensed under the MIT license
*/
/*! UMD WRAPPER */
`
export default () => {
return {
entry: {
'jquery.mockjax': path.resolve(import.meta.dirname, 'src', 'attach.mjs'),
'jquery.mockjax.min': path.resolve(import.meta.dirname, 'src', 'attach.mjs'),
},
output: {
path: path.resolve(import.meta.dirname, 'dist'),
filename: '[name].js'
},
externals: {
jquery: 'jQuery'
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
include: /\.min\.js$/,
terserOptions: {
format: {
comments: /^!/
},
compress: {
drop_console: false,
drop_debugger: true
},
mangle: false
},
extractComments: false
})
]
},
plugins: [
new webpack.BannerPlugin({
banner: banner,
raw: true,
entryOnly: true
}),
new WebpackCustomUMD()
],
resolve: {
extensions: ['.mjs']
}
}
}