🔧 Vue build uses Env vars when specified

This commit is contained in:
Alicia Sykes 2021-08-19 20:14:50 +01:00
parent 59f5decdec
commit 9d7b0d5bc5
2 changed files with 31 additions and 9 deletions

5
.env
View File

@ -0,0 +1,5 @@
# Store environmental variables here. All variables are optional.
# PORT=4000 # The port to expose the running application on
# NODE_ENV=production # Can be either development, production or test
# BASE_URL=/ # The default base path for serving up static assets

View File

@ -1,11 +1,29 @@
/**
* Global config for the main Vue app. ES7 not supported here.
* See docs for all config options: https://cli.vuejs.org/config
*/
const webpack = require('webpack');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const WebpackBuildNotifierPlugin = require('webpack-build-notifier');
// Get current version
process.env.VUE_APP_VERSION = require('./package.json').version;
const { version } = require('./package.json');
// Set the current version, for use within the app
process.env.VUE_APP_VERSION = version;
// Make banner text, for output files
const banner = (() => {
const now = new Date();
const line1 = `Dashy ${version}. Built at ${now.toLocaleTimeString()} on ${now.toLocaleDateString()}`;
const line2 = `Licensed under MIT - (C) Alicia Sykes ${now.getFullYear()}`;
const line3 = 'Code + docs: https://github.com/lissy93/dashy';
return `${line1}\n${line2}\n${line3}`;
})();
// Specify and export the main Vue app config
module.exports = {
publicPath: process.env.BASE_URL, // || './',
publicPath: process.env.BASE_URL,
integrity: true,
chainWebpack: config => {
config.module.rules.delete('svg');
},
@ -17,15 +35,13 @@ module.exports = {
],
},
plugins: [
// Display progress bar while building
new ProgressBarPlugin(),
new WebpackBuildNotifierPlugin({
title: 'Dashy Build Complete',
logo: './public/web-icons/dashy-logo.png',
suppressSuccess: true,
showDuration: true,
}),
// Insert banner into output chunks
new webpack.BannerPlugin({ banner }),
],
},
// Specify resources for PWA / mobile support
pwa: {
name: 'Dashy',
manifestPath: './manifest.json',
@ -40,6 +56,7 @@ module.exports = {
msTileImage: './web-icons/dashy-logo.png',
},
},
// Specify page for app entry point
pages: {
dashy: {
entry: 'src/main.js',