removed import for config.json for fetch

This commit is contained in:
vitorsemeano 2020-10-18 22:31:46 +01:00
parent 9030aa2817
commit 723a19cd8b
2 changed files with 21 additions and 4 deletions

View File

@ -43,9 +43,16 @@ async function fetchLocal(url, options) {
async function getConfig() {
if (data) return Promise.resolve(data);
try {
data = (await import('../../config.json')).default;
const response = await fetchLocal('config.json', {
cache: 'no-cache'
});
if (!response.ok) {
throw new Error('network response was not ok');
}
data = await response.json();
console.dir(data);
return data;
} catch (error) {
console.warn('failed to fetch the web config file:', error);
@ -55,9 +62,15 @@ async function getConfig() {
async function getDefaultConfig() {
try {
data = (await import('../../config.template.json')).default;
const response = await fetchLocal('config.template.json', {
cache: 'no-cache'
});
console.dir(data);
if (!response.ok) {
throw new Error('network response was not ok');
}
data = await response.json();
return data;
} catch (error) {
console.error('failed to fetch the default web config file:', error);

View File

@ -15,6 +15,10 @@ module.exports = {
new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [
{
from: 'config*.json',
to: ''
},
{
from: 'themes/',
to: 'themes/'