-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
100 lines (98 loc) · 2.33 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
const path = require('path')
const { VueLoaderPlugin } = require('vue-loader') // Support Vue's SFCs
const TerserPlugin = require('terser-webpack-plugin') // Minimize code
const webpack = require('webpack')
const package = require('./package.json')
module.exports = (env) => {
const config = {
entry: './src/main.js',
output: {
filename: env.RUNTIME ? 'jsee.runtime.js' : 'jsee.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/dist/', // Should fix Uncaught Error when downloaded: Automatic publicPath is not supported in this browser
library: {
type: 'umd',
name: 'JSEE',
export: 'default',
},
},
// Define loaders
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader'
},
{
test: /\.html/,
type: 'asset/source'
},
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader',
]
},
{
test: /worker\.js$/,
loader: "worker-loader",
options: {
inline: 'no-fallback'
},
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader'
]
}
]
},
plugins: [
new VueLoaderPlugin(),
// Replace those values in the code
new webpack.DefinePlugin({
'VERSION': JSON.stringify(package.version),
'RUNTIME': JSON.stringify(env.RUNTIME),
})
],
// Load different versions of vue based on RUNTIME value
resolve: {
alias: {
vue$: env.RUNTIME
? 'vue/dist/vue.runtime.esm-bundler.js'
: 'vue/dist/vue.esm-bundler'
},
},
// Update recommended size limit
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000
},
// Remove comments
optimization: {
minimize: true,
minimizer: [new TerserPlugin({
extractComments: false,
terserOptions: {
format: {
comments: false,
},
}
})],
},
// Source map
devtool: env.DEVELOPMENT
? 'eval-source-map'
: false
}
return config
}