Webpack: switch build directory to 'static' instead of 'static/packs', fix sw.js
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user