From 0216207a51b6a141d9a8ef1cb82a021cf45bf705 Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 8 Nov 2023 05:16:38 -0800 Subject: [PATCH] Update webpack public URL to fix auth page --- _websrc/master.config.js | 30 +++++++++++++++--------------- _websrc/webpack.config.js | 28 ++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/_websrc/master.config.js b/_websrc/master.config.js index af03d3fe0..bf8bf3ce7 100644 --- a/_websrc/master.config.js +++ b/_websrc/master.config.js @@ -23,23 +23,23 @@ module.exports = { browsersync: { browsers: [ - // "Google Chrome Canary", - // "Google Chrome", - // "Firefox Nightly", - // "Firefox Developer Edition", - // "Firefox", - // "Safari Technology Preview", - // "Safari", - // "Opera", - // "Opera Developer", + // 'Google Chrome Canary', + // 'Google Chrome', + // 'Firefox Nightly', + // 'Firefox Developer Edition', + // 'Firefox', + // 'Safari Technology Preview', + // 'Safari', + // 'Opera', + // 'Opera Developer', ], }, eslintLoader: { - enforce: "pre", + enforce: 'pre', test: /\.js$/, exclude: /node_modules/, - loader: "eslint-loader", + loader: 'eslint-loader', }, imagemin: { @@ -86,15 +86,15 @@ module.exports = { babel: { presets: [ - ["@babel/preset-env", { + ['@babel/preset-env', { modules: false, targets: { browsers: [ - "last 2 versions", - "IE >= 9" + 'last 2 versions', + 'IE >= 9' ] }, - useBuiltIns: "usage", + useBuiltIns: 'usage', }] ] }, diff --git a/_websrc/webpack.config.js b/_websrc/webpack.config.js index 786bc2e20..2c593f9a1 100644 --- a/_websrc/webpack.config.js +++ b/_websrc/webpack.config.js @@ -11,7 +11,11 @@ const path = require('path'); // const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); const argv = require('yargs').argv; -const timestamp = new Date().getTime(); +const yaml = require('js-yaml'); +const jetpack = require('fs-jetpack'); + +const tools = new (require('./libraries/tools.js')); +const configYML = yaml.load(jetpack.read('_config.yml')); module.exports = { mode: 'production', @@ -22,8 +26,8 @@ module.exports = { rules: [ { test: /\.js$/, - use: ["source-map-loader"], - enforce: "pre" + use: ['source-map-loader'], + enforce: 'pre', } ] }, @@ -40,7 +44,8 @@ module.exports = { // chunkFilename: './assets/js/[name].js', // chunkFilename: '[name].js', // path: '/assets/js/', - publicPath: '/assets/js/', + // publicPath: '/assets/js/', + publicPath: `${tools.isServer ? configYML.url : ''}/assets/js/`, // filename: '[name].js' // https://github.com/webpack/webpack/issues/959 @@ -50,15 +55,15 @@ module.exports = { }, filename: (pathData) => { return '[name].js'; - }, - + }, + // https://github.com/webpack/webpack/issues/2329 - // chunkFilename: `chunk.[name].[chunkhash].js?cb=[chunkhash]`, + // chunkFilename: `chunk.[name].[chunkhash].js?cb=[chunkhash]`, // https://stackoverflow.com/questions/39238163/how-to-use-cache-busting-with-webpack // filename: `[name].js?cb=${timestamp}`, - // chunkFilename: `chunk.[name].js?cb=${timestamp}`, + // chunkFilename: `chunk.[name].js?cb=${timestamp}`, // path: '/assets/js/', // umdNamedDefine: false, @@ -96,6 +101,13 @@ module.exports = { // usedExports: false, }, + plugins: [ + // This makes it possible for us to safely use env vars on our code + // new webpack.DefinePlugin({ + // 'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH), + // }), + ], + /* CRITICAL CSS */ // plugins: [ // new CriticalPlugin({