-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from bcgsc/feature/support-subdir-deployment
Feature/support subdir deployment
- Loading branch information
Showing
22 changed files
with
507 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,3 @@ Thumbs.db | |
!/public/mainfest.json | ||
/stats.json | ||
/dist | ||
src/static/graphkb-env-config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ KEYCLOAK_URL=https://keycloakdev.bcgsc.ca/auth | |
API_BASE_URL=https://graphkbdev-api.bcgsc.ca | ||
CONTACT_EMAIL=[email protected] | ||
CONTACT_TICKET_URL=https://www.bcgsc.ca/jira/projects/KBDEV | ||
PUBLIC_PATH=/ | ||
IS_DEMO= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,19 +9,11 @@ const CompressionPlugin = require('compression-webpack-plugin'); | |
const ManifestPlugin = require('webpack-manifest-plugin'); | ||
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin'); | ||
const TerserWebpackPlugin = require('terser-webpack-plugin'); | ||
|
||
|
||
const stripToBaseUrl = (url) => { | ||
const match = /^(https?:\/\/[^/]+)/.exec(url); | ||
const baseAuthUrl = match | ||
? match[1] | ||
: url; | ||
return baseAuthUrl; | ||
}; | ||
const CopyPlugin = require('copy-webpack-plugin'); | ||
|
||
|
||
const createBaseConfig = ({ | ||
env = {}, mode = 'production', sourceMap = false, outputPath, | ||
define = {}, mode = 'production', sourceMap = false, outputPath, baseUrl = '/', | ||
} = {}) => { | ||
const BASE_DIR = path.resolve(__dirname, '../..'); | ||
const SRC_PATH = path.resolve(BASE_DIR, 'src'); | ||
|
@@ -30,18 +22,6 @@ const createBaseConfig = ({ | |
SRC_PATH, | ||
]; | ||
|
||
const ENV_VARS = { | ||
KEYCLOAK_CLIENT_ID: process.env.KEYCLOAK_CLIENT_ID || 'GraphKB', | ||
KEYCLOAK_ROLE: process.env.KEYCLOAK_ROLE || 'GraphKB', | ||
KEYCLOAK_REALM: process.env.KEYCLOAK_REALM || 'PORI', | ||
KEYCLOAK_URL: process.env.KEYCLOAK_URL || 'http://localhost:8888/auth', | ||
API_BASE_URL: process.env.API_BASE_URL || 'http://localhost:8080', | ||
CONTACT_EMAIL: process.env.CONTACT_EMAIL || '[email protected]', | ||
CONTACT_TICKET_URL: process.env.CONTACT_TICKET_URL || 'https://www.bcgsc.ca/jira/projects/KBDEV', | ||
...env | ||
}; | ||
|
||
|
||
const moduleSettings = { | ||
rules: [ | ||
{ | ||
|
@@ -107,6 +87,15 @@ const createBaseConfig = ({ | |
|
||
const plugins = [ | ||
new webpack.HotModuleReplacementPlugin(), | ||
// copy the dynamic env js file | ||
new CopyPlugin({ | ||
patterns: [ | ||
{ | ||
from: path.resolve(SRC_PATH, 'static/graphkb-env-config.js'), | ||
to: outputPath, | ||
}, | ||
], | ||
}), | ||
// separate the css from the main js bundle | ||
new MiniCssExtractPlugin({ | ||
filename: 'static/style/[name].css', | ||
|
@@ -117,14 +106,16 @@ const createBaseConfig = ({ | |
// Copy values of ENV variables in as strings using these defaults (null = unset) | ||
new webpack.DefinePlugin({ | ||
'process.env.npm_package_version': JSON.stringify(process.env.npm_package_version), | ||
'process.NODE_ENV': JSON.stringify(env.NODE_ENV || process.env.NODE_ENV) | ||
'process.env.NODE_ENV': JSON.stringify('production'), | ||
...define, | ||
}), | ||
// template index.html. Required for running the dev-server properly | ||
new HtmlWebpackPlugin({ | ||
template: path.resolve(SRC_PATH, 'static/index.html'), | ||
template: path.resolve(SRC_PATH, 'static/index.ejs'), | ||
filename: 'index.html', | ||
inject: true, | ||
favicon: path.resolve(SRC_PATH, 'static/favicon/favicon.ico'), | ||
baseUrl, | ||
minify: { | ||
removeComments: false, | ||
}, | ||
|
@@ -141,7 +132,7 @@ const createBaseConfig = ({ | |
], | ||
'connect-src': [ | ||
"'self'", | ||
'*' | ||
'*', | ||
], | ||
// TODO: Remove google charts requirement since it requires external load which cannot include nonce/hash | ||
// Then re-add the nonce/hash to scripts | ||
|
@@ -226,7 +217,7 @@ const createBaseConfig = ({ | |
path: outputPath, | ||
filename: 'static/js/[name].bundle.js', | ||
chunkFilename: 'static/js/[name].[chunkhash].chunk.js', | ||
publicPath: '/', | ||
publicPath: '', | ||
}, | ||
devServer: { | ||
host: process.env.HOSTNAME || 'localhost', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,19 @@ const DIST = path.resolve(__dirname, '../../dist/development'); | |
|
||
module.exports = createBaseConfig({ | ||
outputPath: DIST, | ||
env: { | ||
API_BASE_URL: 'https://graphkbdev-api.bcgsc.ca', | ||
KEYCLOAK_URL: 'https://keycloakdev.bcgsc.ca/auth', | ||
KEYCLOAK_REALM: 'GSC', | ||
NODE_ENV: 'development', | ||
define: { | ||
'window._env_': JSON.stringify({ | ||
API_BASE_URL: 'https://graphkbdev-api.bcgsc.ca', | ||
KEYCLOAK_URL: 'https://keycloakdev.bcgsc.ca/auth', | ||
KEYCLOAK_REALM: 'GSC', | ||
KEYCLOAK_CLIENT_ID: 'GraphKB', | ||
KEYCLOAK_ROLE: 'GraphKB', | ||
CONTACT_EMAIL: '[email protected]', | ||
CONTACT_TICKET_URL: 'https://www.bcgsc.ca/jira/projects/KBDEV', | ||
PUBLIC_PATH: '/', | ||
IS_DEMO: false, | ||
}), | ||
'process.env.NODE_ENV': JSON.stringify('development'), | ||
}, | ||
sourceMap: true, | ||
mode: 'development', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,19 @@ const DIST = path.resolve(__dirname, '../../dist/production'); | |
|
||
module.exports = createBaseConfig({ | ||
outputPath: DIST, | ||
env: { | ||
API_BASE_URL: `http://${process.env.HOSTNAME}:8080`, | ||
KEYCLOAK_URL: 'https://keycloakdev.bcgsc.ca/auth', | ||
KEYCLOAK_REALM: 'GSC', | ||
NODE_ENV: 'local', | ||
define: { | ||
'window._env_': JSON.stringify({ | ||
API_BASE_URL: `http://${process.env.HOSTNAME}:8080`, | ||
KEYCLOAK_URL: 'https://keycloakdev.bcgsc.ca/auth', | ||
KEYCLOAK_REALM: 'GSC', | ||
KEYCLOAK_CLIENT_ID: 'GraphKB', | ||
KEYCLOAK_ROLE: 'GraphKB', | ||
CONTACT_EMAIL: '[email protected]', | ||
CONTACT_TICKET_URL: 'https://www.bcgsc.ca/jira/projects/KBDEV', | ||
PUBLIC_PATH: '/', | ||
IS_DEMO: false, | ||
}), | ||
'process.env.NODE_ENV': JSON.stringify('local'), | ||
}, | ||
sourceMap: true, | ||
mode: 'development', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,18 @@ const DIST = path.resolve(__dirname, '../../dist/production'); | |
module.exports = createBaseConfig({ | ||
outputPath: DIST, | ||
mode: 'production', | ||
env: { | ||
API_BASE_URL: 'https://graphkb-api.bcgsc.ca', | ||
KEYCLOAK_URL: 'https://sso.bcgsc.ca/auth', | ||
KEYCLOAK_REALM: 'GSC', | ||
NODE_ENV: 'production', | ||
define: { | ||
'window._env_': JSON.stringify({ | ||
API_BASE_URL: 'https://graphkb-api.bcgsc.ca', | ||
KEYCLOAK_URL: 'https://sso.bcgsc.ca/auth', | ||
KEYCLOAK_REALM: 'GSC', | ||
KEYCLOAK_CLIENT_ID: 'GraphKB', | ||
KEYCLOAK_ROLE: 'GraphKB', | ||
CONTACT_EMAIL: '[email protected]', | ||
CONTACT_TICKET_URL: 'https://www.bcgsc.ca/jira/projects/KBDEV', | ||
PUBLIC_PATH: '/', | ||
IS_DEMO: false, | ||
}), | ||
}, | ||
sourceMap: false, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,18 @@ const DIST = path.resolve(__dirname, '../../dist/staging'); | |
module.exports = createBaseConfig({ | ||
outputPath: DIST, | ||
mode: 'production', | ||
env: { | ||
API_BASE_URL: 'https://graphkbstaging-api.bcgsc.ca', | ||
KEYCLOAK_URL: 'https://keycloakdev.bcgsc.ca/auth', | ||
KEYCLOAK_REALM: 'GSC', | ||
NODE_ENV: 'production', | ||
define: { | ||
'window._env_': JSON.stringify({ | ||
API_BASE_URL: 'https://graphkbstaging-api.bcgsc.ca', | ||
KEYCLOAK_URL: 'https://keycloakdev.bcgsc.ca/auth', | ||
KEYCLOAK_REALM: 'GSC', | ||
KEYCLOAK_CLIENT_ID: 'GraphKB', | ||
KEYCLOAK_ROLE: 'GraphKB', | ||
CONTACT_EMAIL: '[email protected]', | ||
CONTACT_TICKET_URL: 'https://www.bcgsc.ca/jira/projects/KBDEV', | ||
PUBLIC_PATH: '/', | ||
IS_DEMO: false, | ||
}), | ||
}, | ||
sourceMap: false, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.