Skip to content

Commit

Permalink
🔧 Vue build uses Env vars when specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 committed Aug 19, 2021
1 parent 59f5dec commit 9d7b0d5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -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
35 changes: 26 additions & 9 deletions vue.config.js
Original file line number Diff line number Diff line change
@@ -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');
},
Expand All @@ -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',
Expand All @@ -40,6 +56,7 @@ module.exports = {
msTileImage: './web-icons/dashy-logo.png',
},
},
// Specify page for app entry point
pages: {
dashy: {
entry: 'src/main.js',
Expand Down

0 comments on commit 9d7b0d5

Please sign in to comment.