Webpack: switch build directory to 'static' instead of 'static/packs', fix sw.js

This commit is contained in:
Alex Gleason
2021-07-21 16:13:24 -05:00
parent 969653eaa4
commit f061954fdb
6 changed files with 32 additions and 41 deletions

View File

@@ -11,10 +11,6 @@ const settings = {
extensions: [ '.mjs', '.js', '.sass', '.scss', '.css', '.module.sass', '.module.scss', '.module.css', '.png', '.svg', '.gif', '.jpeg', '.jpg' ],
};
function removeOuterSlashes(string) {
return string.replace(/^\/*/, '').replace(/\/*$/, '');
}
function getPublicOutputPath() {
if (env.NODE_ENV === 'test') {
return 'packs-test';
@@ -23,25 +19,14 @@ function getPublicOutputPath() {
return 'packs';
}
function formatPublicPath(host = '', path = '') {
let formattedHost = removeOuterSlashes(host);
if (formattedHost && !/^http/i.test(formattedHost)) {
formattedHost = `//${formattedHost}`;
}
const formattedPath = removeOuterSlashes(path);
return `${formattedHost}/${formattedPath}/`;
function packsPath(path) {
return join(settings.public_output_path, path);
}
const output = {
path: join(__dirname, '..', 'static', settings.public_output_path),
publicPath: formatPublicPath(env.CDN_HOST, settings.public_output_path),
};
module.exports = {
settings,
env: {
CDN_HOST: env.CDN_HOST,
NODE_ENV: env.NODE_ENV,
},
output,
packsPath,
};