forked from twikoojs/twikoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
71 lines (70 loc) · 1.86 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
const path = require('path')
const webpack = require('webpack')
const CopyPlugin = require('copy-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const ROOT_PATH = path.resolve(__dirname)
const BUILD_PATH = path.resolve(ROOT_PATH, 'dist')
const version = require('./package.json').version
const TerserPlugin = require('terser-webpack-plugin')
const banner =
'Twikoo v' + version + '\n' +
'(c) 2020-' + new Date().getFullYear() + ' iMaeGoo\n' +
'Released under the MIT License.\n' +
'Last Update: ' + (new Date()).toLocaleString()
module.exports = {
module: {
rules: [
{ test: /\.vue$/, loader: 'vue-loader' },
{ test: /\.css$/, use: ['vue-style-loader', 'css-loader'] },
{ test: /\.svg$/, loader: 'svg-inline-loader' },
{ test: /\.js$/, use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env'], plugins: ['@babel/plugin-transform-modules-commonjs', '@babel/transform-runtime'] } } }
]
},
entry: {
/* eslint-disable-next-line quote-props */
'twikoo': './src/js/main.js',
'twikoo.all': './src/js/main.all.js'
},
output: {
path: BUILD_PATH,
filename: '[name].min.js',
library: 'twikoo',
libraryTarget: 'umd'
},
target: ['web', 'es5'],
plugins: [
new webpack.BannerPlugin(banner),
new CopyPlugin({
patterns: [
{ from: 'demo/', to: './' }
]
}),
new VueLoaderPlugin(),
new TerserPlugin({
parallel: 4,
terserOptions: {
ecma: 5,
toplevel: true,
ie8: true,
safari10: true
}
})
],
devServer: {
static: [{
directory: BUILD_PATH,
publicPath: '/dist/',
serveIndex: true,
watch: true
}],
port: 9820,
host: 'localhost',
open: true,
hot: true,
compress: true
},
performance: {
maxEntrypointSize: 524288,
maxAssetSize: 524288
}
}