-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
vue.config.js
100 lines (88 loc) · 2.59 KB
/
vue.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
/**
* Dashy is built using Vue (2). This is the main Vue and Webpack configuration
*
* User Configurable Options:
* - NODE_ENV: Sets the app mode (production, development, test).
* - BASE_URL: Root URL for the app deployment (defaults to '/').
* - INTEGRITY: Enables SRI, set to 'true' to activate.
* - USER_DATA_DIR: Sets an alternative dir for user data (defaults ./user-data).
* - IS_DOCKER: Indicates if running in a Docker container.
* - IS_SERVER: Indicates if running as a server (as opposed to static build).
*
* Documentation:
* - Vue CLI Config options: https://cli.vuejs.org/config
* - For Dashy docs, see the repo: https://github.com/lissy93/dashy
*
* Note: ES7 syntax is not supported in this configuration context.
* Licensed under the MIT License, (C) Alicia Sykes 2024 (see LICENSE for details).
*/
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
// Get app mode: production, development, or test
const mode = process.env.NODE_ENV || 'production';
// Get current version
process.env.VUE_APP_VERSION = require('./package.json').version;
// Get default info for PWA
const { pwa } = require('./src/utils/defaults');
// Get base URL
const publicPath = process.env.BASE_URL || '/';
// Should enable Subresource Integrity (SRI) on link and script tags
const integrity = process.env.INTEGRITY === 'true';
// If neither env vars are set, then it's a static build
const isServer = process.env.IS_DOCKER || process.env.IS_SERVER || false;
// Use copy-webpack-plugin to copy user-data to dist IF not running as a server
const plugins = !isServer ? [
new CopyWebpackPlugin({
patterns: [
{ from: './user-data', to: './' },
],
}),
] : [];
// Webpack Config
const configureWebpack = {
devtool: 'source-map',
mode,
plugins,
module: {
rules: [
{ test: /.svg$/, loader: 'vue-svg-loader' },
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: { appendTsSuffixTo: [/\.vue$/] },
},
],
},
performance: {
maxEntrypointSize: 10000000,
maxAssetSize: 10000000,
},
};
// Development server config
const devServer = {
contentBase: [
path.join(__dirname, 'public'),
path.join(__dirname, process.env.USER_DATA_DIR || 'user-data'),
],
watchContentBase: true,
publicPath: '/',
};
// Application pages
const pages = {
dashy: {
entry: 'src/main.js',
filename: 'index.html',
},
};
// Export the main Vue app config
module.exports = {
publicPath,
pwa,
integrity,
configureWebpack,
pages,
devServer,
chainWebpack: config => {
config.module.rules.delete('svg');
},
};