1- const fs = require ( 'fs' )
2- const path = require ( 'path' )
3- const util = require ( 'util' )
4-
5- const findUp = require ( 'find-up' )
61const makeDir = require ( 'make-dir' )
72
83const { restoreCache, saveCache } = require ( './helpers/cacheBuild' )
94const copyUnstableIncludedDirs = require ( './helpers/copyUnstableIncludedDirs' )
105const doesNotNeedPlugin = require ( './helpers/doesNotNeedPlugin' )
116const getNextConfig = require ( './helpers/getNextConfig' )
127const validateNextUsage = require ( './helpers/validateNextUsage' )
8+ const verifyBuildTarget = require ( './helpers/verifyBuildTarget' )
139const nextOnNetlify = require ( './src/index.js' )
1410
15- const pWriteFile = util . promisify ( fs . writeFile )
16-
1711// * Helpful Plugin Context *
1812// - Between the prebuild and build steps, the project's build command is run
1913// - Between the build and postbuild steps, any functions are bundled
@@ -28,8 +22,13 @@ module.exports = {
2822 if ( hasNoPackageJson ) {
2923 return failBuild ( 'Could not find a package.json for this project' )
3024 }
25+
26+ if ( doesNotNeedPlugin ( { netlifyConfig, packageJson, failBuild } ) ) {
27+ return
28+ }
29+
3130 // Populates the correct config if needed
32- await doesNotNeedPlugin ( { netlifyConfig, packageJson, failBuild } )
31+ await verifyBuildTarget ( { netlifyConfig, packageJson, failBuild } )
3332
3433 // Because we memoize nextConfig, we need to do this after the write file
3534 const nextConfig = await getNextConfig ( utils . failBuild )
@@ -51,7 +50,7 @@ module.exports = {
5150 } ) {
5251 const { failBuild } = utils . build
5352
54- if ( await doesNotNeedPlugin ( { netlifyConfig, packageJson, failBuild } ) ) {
53+ if ( doesNotNeedPlugin ( { netlifyConfig, packageJson, failBuild } ) ) {
5554 return
5655 }
5756
@@ -63,7 +62,7 @@ module.exports = {
6362 } ,
6463
6564 async onPostBuild ( { netlifyConfig, packageJson, constants : { FUNCTIONS_DIST } , utils } ) {
66- if ( await doesNotNeedPlugin ( { netlifyConfig, packageJson, utils } ) ) {
65+ if ( doesNotNeedPlugin ( { netlifyConfig, packageJson, utils } ) ) {
6766 return
6867 }
6968
0 commit comments