UPTADE
Updated title from Netlify.toml written at npm "postinstall" not being detected by build engine fro clarity
Hi team,
PROBLEM
In my current use case, I am trying to write a custom netlify.toml before each build. There are multiple reasons why, but the most important reasons are:
- I cant track
netlify.tomlon git (this is on purpose) - I want to make sure end-users donβt change or overwrite our
netlify.toml - Our
netlify.tomlhave custom build plugins
ATTEMPED SOLUTION
I have configured a "postinstall" script which executes the command:
node --eval "require('@myprivateorg/netlify-toml')"
This command effectively writes a netlify.toml to the root of the project. This works perfectly fine locally.
Unfortunately, despite the fact that the command executes successfully after the project dependencies are installed , it appears that itβs somehow written too late for the netlify build engine to detect it. i.e our netlify.toml config is being ignored and our custom plugins are not being loaded.
PROBLEM LOG
7:39:51 AM: [5/5] Building fresh packages...
7:39:57 AM: $ node --eval "require('@myorg/netlify-toml')"
7:39:59 AM: Created default netlify.toml at /opt/build/repo <------ β
7:39:59 AM: Done in 61.65s.
7:39:59 AM: NPM modules installed using Yarn
7:39:59 AM: Started restoring cached go cache
7:39:59 AM: Finished restoring cached go cache
7:39:59 AM: go version go1.14.4 linux/amd64
7:39:59 AM: go version go1.14.4 linux/amd64
7:39:59 AM: Installing missing commands
7:39:59 AM: Verify run directory
7:40:00 AM: β
7:40:00 AM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
7:40:00 AM: Netlify Build
7:40:00 AM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
7:40:00 AM: β
7:40:00 AM: β― Version
7:40:00 AM: @netlify/build 17.9.2
7:40:00 AM: β
7:40:00 AM: β― Flags
7:40:00 AM: baseRelDir: true
7:40:00 AM: deployId: 61128f70de851d43819b2cb8
7:40:00 AM: β
7:40:00 AM: β― Current directory
7:40:00 AM: /opt/build/repo
7:40:00 AM: β
7:40:00 AM: β― Config file <--- π« Not detecting the netlify.toml we just wrote
7:40:00 AM: No config file was defined: using default values.
7:40:00 AM: β
7:40:00 AM: β― Context
7:40:00 AM: production
7:40:00 AM: β
7:40:00 AM: β― Loading plugins <---- π« Not detecting our netlify.toml build plugins
7:40:00 AM: - @netlify/plugin-nextjs@3.8.0 from Netlify app and package.json 7:40:00 AM: <--- β οΈ running because its also added via the UI but ignoring our version
EXPECTED RESULT
2:15:54 PM: β― Loading plugins
2:15:54 PM: - @netlify/plugin-nextjs@3.8.0 from netlify.toml and package.json
2:15:54 PM: - @myorg/netlify-xx@0.0.105 from netlify.toml and package.json
2:15:54 PM: - @myorg/netlify-yy@0.0.105 from netlify.toml and package.json
FULL DEPLOYMENT LOGS
Full failing deploy logs @ deploy id 6112981897b0290007963e38
Am i doing this wrong?
Is there a way to run a script before the netlify build engine kicks in?
Thanks for your help
JP
