mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-13 09:17:20 +00:00
Error out if required (json) configs are missing/corrupted.
This commit is contained in:
@@ -12,19 +12,8 @@ const CopyPlugin = require('copy-webpack-plugin');
|
||||
const WatchTimestampsPlugin = require('./config/watch-timestamps-plugin');
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
|
||||
function parseJson(text, fallback) {
|
||||
try {
|
||||
return JSON.parse(text);
|
||||
}
|
||||
catch (e) { }
|
||||
return fallback || {};
|
||||
}
|
||||
|
||||
function readFile(filename) {
|
||||
try {
|
||||
return fs.readFileSync(filename);
|
||||
}
|
||||
catch (e) {}
|
||||
function readJson(filename) {
|
||||
return JSON.parse(fs.readFileSync(filename));
|
||||
}
|
||||
|
||||
module.exports = function(_, env) {
|
||||
@@ -35,11 +24,6 @@ module.exports = function(_, env) {
|
||||
path.join(__dirname, 'src/routes')
|
||||
];
|
||||
|
||||
let babelRc = parseJson(readFile('.babelrc'));
|
||||
babelRc.babelrc = false;
|
||||
|
||||
let manifest = parseJson(readFile('./src/manifest.json'));
|
||||
|
||||
return {
|
||||
mode: env.mode || 'development',
|
||||
entry: path.join(__dirname, 'config/client-boot.js'),
|
||||
@@ -75,7 +59,7 @@ module.exports = function(_, env) {
|
||||
{
|
||||
test: /\.(tsx?|jsx?)$/,
|
||||
loader: 'babel-loader',
|
||||
options: babelRc
|
||||
options: Object.assign(readJson('.babelrc'), { babelrc: false })
|
||||
},
|
||||
{
|
||||
test: /\.(scss|sass)$/,
|
||||
@@ -179,7 +163,7 @@ module.exports = function(_, env) {
|
||||
removeStyleLinkTypeAttributes: true,
|
||||
removeComments: true
|
||||
},
|
||||
manifest,
|
||||
manifest: readJson('./src/manifest.json'),
|
||||
|
||||
/** @todo Finish implementing prerendering similar to that of Preact CLI. */
|
||||
prerender() {
|
||||
|
||||
Reference in New Issue
Block a user