2021-08-19 21:14:50 +02:00
|
|
|
/**
|
2024-04-20 00:09:41 +02:00
|
|
|
* 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).
|
2021-08-19 21:14:50 +02:00
|
|
|
*/
|
2021-06-23 16:34:18 +02:00
|
|
|
|
2024-04-01 14:38:04 +02:00
|
|
|
const path = require('path');
|
2024-04-16 22:47:12 +02:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2024-04-01 14:38:04 +02:00
|
|
|
|
2024-04-20 00:09:41 +02:00
|
|
|
// Get app mode: production, development, or test
|
2021-12-21 20:46:32 +01:00
|
|
|
const mode = process.env.NODE_ENV || 'production';
|
|
|
|
|
2021-06-22 23:28:08 +02:00
|
|
|
// Get current version
|
2021-08-20 01:36:38 +02:00
|
|
|
process.env.VUE_APP_VERSION = require('./package.json').version;
|
2021-08-19 21:14:50 +02:00
|
|
|
|
2021-09-04 21:01:25 +02:00
|
|
|
// 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';
|
|
|
|
|
2024-04-20 00:09:41 +02:00
|
|
|
// If neither env vars are set, then it's a static build
|
|
|
|
const isServer = process.env.IS_DOCKER || process.env.IS_SERVER || false;
|
2024-04-16 22:47:12 +02:00
|
|
|
|
2024-04-20 00:09:41 +02:00
|
|
|
// Use copy-webpack-plugin to copy user-data to dist IF not running as a server
|
|
|
|
const plugins = !isServer ? [
|
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
2024-04-20 12:25:36 +02:00
|
|
|
{ from: './user-data', to: './' },
|
2024-04-20 00:09:41 +02:00
|
|
|
],
|
|
|
|
}),
|
|
|
|
] : [];
|
2024-04-16 22:47:12 +02:00
|
|
|
|
2021-09-04 21:01:25 +02:00
|
|
|
// Webpack Config
|
|
|
|
const configureWebpack = {
|
2024-05-09 19:13:01 +02:00
|
|
|
devtool: 'source-map',
|
2021-12-21 20:46:32 +01:00
|
|
|
mode,
|
2024-04-20 00:09:41 +02:00
|
|
|
plugins,
|
2021-09-04 21:01:25 +02:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{ test: /.svg$/, loader: 'vue-svg-loader' },
|
2024-04-13 15:07:06 +02:00
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
loader: 'ts-loader',
|
|
|
|
options: { appendTsSuffixTo: [/\.vue$/] },
|
|
|
|
},
|
2021-06-23 16:34:18 +02:00
|
|
|
],
|
2021-04-17 19:42:38 +02:00
|
|
|
},
|
2024-04-13 15:07:06 +02:00
|
|
|
performance: {
|
|
|
|
maxEntrypointSize: 10000000,
|
|
|
|
maxAssetSize: 10000000,
|
|
|
|
},
|
2021-09-04 21:01:25 +02:00
|
|
|
};
|
|
|
|
|
2024-04-01 14:38:04 +02:00
|
|
|
// Development server config
|
|
|
|
const devServer = {
|
|
|
|
contentBase: [
|
|
|
|
path.join(__dirname, 'public'),
|
2024-04-13 13:33:16 +02:00
|
|
|
path.join(__dirname, process.env.USER_DATA_DIR || 'user-data'),
|
2024-04-01 14:38:04 +02:00
|
|
|
],
|
|
|
|
watchContentBase: true,
|
|
|
|
publicPath: '/',
|
|
|
|
};
|
|
|
|
|
2021-09-04 21:01:25 +02:00
|
|
|
// Application pages
|
|
|
|
const pages = {
|
|
|
|
dashy: {
|
|
|
|
entry: 'src/main.js',
|
|
|
|
filename: 'index.html',
|
2021-05-31 18:01:00 +02:00
|
|
|
},
|
2021-09-04 21:01:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Export the main Vue app config
|
|
|
|
module.exports = {
|
|
|
|
publicPath,
|
|
|
|
pwa,
|
|
|
|
integrity,
|
|
|
|
configureWebpack,
|
|
|
|
pages,
|
2024-04-01 14:38:04 +02:00
|
|
|
devServer,
|
2021-09-04 21:01:25 +02:00
|
|
|
chainWebpack: config => {
|
|
|
|
config.module.rules.delete('svg');
|
2021-06-20 18:01:00 +02:00
|
|
|
},
|
2021-04-17 19:42:38 +02:00
|
|
|
};
|