@seliseblocks/next-filters
Version:
Next.js Generic Packages for Filters
27 lines (22 loc) • 954 B
JavaScript
/**
* This script is used to add the package to the list of transpiled packages in next.config.js.
* This is necessary because the package is not transpiled by default.
*/
const { readJson, writeFile, CONSTANTS } = require('./init');
console.log('Post install script is running...');
const packageJson = readJson(CONSTANTS.PACKAGE_JSON_PATH);
const hasNextConfig = require('fs').existsSync(CONSTANTS.CONFIG_PATH);
if (!hasNextConfig) {
console.log('No next.config.js file found. Skipping post install script.');
return;
}
const nextConfig = require(CONSTANTS.CONFIG_PATH);
if (nextConfig.hasOwnProperty(CONSTANTS.NEXT_TRANSPILE_KEY)) {
if (!nextConfig.transpilePackages.includes(packageJson.name)) {
nextConfig.transpilePackages.push(packageJson.name);
}
} else {
nextConfig.transpilePackages = [packageJson.name];
}
writeFile(nextConfig, CONSTANTS.CONFIG_PATH);
console.log('Post install script has been executed successfully!\n');