Skip to content

Instantly share code, notes, and snippets.

@chowdhary987
Forked from DavidWells/netlify.toml
Created January 12, 2021 14:23
Show Gist options
  • Select an option

  • Save chowdhary987/aa5d6ad0d1de07e7e800c39e953133f2 to your computer and use it in GitHub Desktop.

Select an option

Save chowdhary987/aa5d6ad0d1de07e7e800c39e953133f2 to your computer and use it in GitHub Desktop.

Revisions

  1. @DavidWells DavidWells revised this gist Dec 9, 2019. 2 changed files with 6 additions and 7 deletions.
    8 changes: 1 addition & 7 deletions netlify.toml
    Original file line number Diff line number Diff line change
    @@ -40,21 +40,18 @@ ID = "Your_Site_ID"
    publish = "output/"
    command = "make publish"
    environment = { ACCESS_TOKEN = "super secret", NODE_ENV = "8.0.1" }

    # Deploy Preview context: All Deploy Previews (https://www.netlify.com/blog/2016/07/20/introducing-deploy-previews-in-netlify/)
    # will inherit these settings.
    [context.deploy-preview]
    publish = "dist/"
    # Here is another way to define context specific environment variables
    [context.deploy-preview.environment]
    ACCESS_TOKEN = "not so secret"

    # Branch Deploy context: All deploys that are not resulting from a Pull/Merge Request and not from the primary, linked branch will inherit these settings.
    [context.branch-deploy]
    command = "echo branch"
    [context.branch-deploy.environment]
    NODE_ENV = "development"

    # Specific branch context: Deploys from this branch
    # will take these settings and override their
    # current ones.
    @@ -65,12 +62,11 @@ ID = "Your_Site_ID"
    [context."feat/branch"]
    command = "echo 'special branch'"
    base = "branch"

    # A basic redirects rule
    [[redirects]]
    from = "/*"
    to = "/blog/:splat"

    # The following show an example redirects rule with all the supported properties.
    [[redirects]]
    from = "/old-path"
    @@ -88,13 +84,11 @@ ID = "Your_Site_ID"
    [redirects.headers]
    X-From = "Netlify"
    X-Api-Key = "some-api-key-string"

    # The following redirect is intended for use with most SPA's that handles routing internally.
    [[redirects]]
    from = "/*"
    to = "/index.html"
    status = 200

    [[redirects]]
    from = "/api/*"
    to = "https://us-central1-netlify-intercom.cloudfunctions.net/readHeaders/:splat"
    5 changes: 5 additions & 0 deletions netlify.yml
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    Settings:
    ID: Your_Site_ID

    build:
    base: project/
    publish: project/build-output/
    @@ -18,11 +19,13 @@ build:
    pretty_urls: true
    images:
    compress: true

    template:
    environment:
    YOUR_ENV_KEYS_NEEDED: Enter in the ENV key here
    incoming-hooks:
    - Service-1

    context:
    production:
    publish: output/
    @@ -44,6 +47,7 @@ context:
    feat/branch:
    command: echo 'special branch'
    base: branch

    redirects:
    - from: /*
    to: '/blog/:splat'
    @@ -78,6 +82,7 @@ redirects:
    headers:
    X-From: Netlify
    X-Api-Key: some-api-key-string

    headers:
    - for: /*
    values:
  2. @DavidWells DavidWells revised this gist Dec 9, 2019. 1 changed file with 91 additions and 0 deletions.
    91 changes: 91 additions & 0 deletions netlify.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,91 @@
    Settings:
    ID: Your_Site_ID
    build:
    base: project/
    publish: project/build-output/
    command: echo 'default context'
    functions: project/functions/
    ignore: git diff --quiet HEAD^ HEAD sub_dir/
    processing:
    skip_processing: false
    css:
    bundle: true
    minify: false
    js:
    bundle: true
    minify: false
    html:
    pretty_urls: true
    images:
    compress: true
    template:
    environment:
    YOUR_ENV_KEYS_NEEDED: Enter in the ENV key here
    incoming-hooks:
    - Service-1
    context:
    production:
    publish: output/
    command: make publish
    environment:
    ACCESS_TOKEN: super secret
    NODE_ENV: 8.0.1
    deploy-preview:
    publish: dist/
    environment:
    ACCESS_TOKEN: not so secret
    branch-deploy:
    command: echo branch
    environment:
    NODE_ENV: development
    staging:
    command: echo 'staging'
    base: staging
    feat/branch:
    command: echo 'special branch'
    base: branch
    redirects:
    - from: /*
    to: '/blog/:splat'
    - from: /old-path
    to: /new-path
    status: 301
    force: false
    query:
    path: ':path'
    conditions:
    Language:
    - en
    Country:
    - US
    Role:
    - admin
    signed: API_SIGNATURE_TOKEN
    headers:
    X-From: Netlify
    X-Api-Key: some-api-key-string
    - from: /*
    to: /index.html
    status: 200
    - from: /api/*
    to: 'https://us-central1-netlify-intercom.cloudfunctions.net/readHeaders/:splat'
    status: 200
    force: true
    conditions:
    Role:
    - admin
    - cms
    headers:
    X-From: Netlify
    X-Api-Key: some-api-key-string
    headers:
    - for: /*
    values:
    X-Frame-Options: DENY
    X-XSS-Protection: 1; mode=block
    Content-Security-Policy: 'frame-ancestors https://www.facebook.com'
    Link: |2-
    </assets/css/base.css>; rel=preload; as=style, \
    </assets/css/base2.css>; rel=preload; as=style, \
    </assets/css/base3.css>; rel=preload; as=style
    Basic-Auth: 'someuser:somepassword anotheruser:anotherpassword'
  3. @DavidWells DavidWells revised this gist Dec 9, 2019. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions netlify.toml
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,21 @@ ID = "Your_Site_ID"
    command = "echo 'default context'"
    # This is where we will look for your lambda functions
    functions = "project/functions/"
    # Ignore build command if exit 0
    ignore = "git diff --quiet HEAD^ HEAD sub_dir/"
    # If skip_processing = true, all other settings are ignored
    [build.processing]
    skip_processing = false
    [build.processing.css]
    bundle = true
    minify = false
    [build.processing.js]
    bundle = true
    minify = false
    [build.processing.html]
    pretty_urls = true
    [build.processing.images]
    compress = true

    # Set enviroment variable prompts for templates
    [template.environment]
  4. @DavidWells DavidWells created this gist Sep 6, 2018.
    106 changes: 106 additions & 0 deletions netlify.toml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,106 @@
    [Settings]
    ID = "Your_Site_ID"

    # Settings in the [build] context are global and are applied to all contexts unless otherwise overridden by more specific contexts.

    [build]
    # This is the directory to change to before starting a build.
    base = "project/"
    # NOTE: This is where we will look for package.json/.nvmrc/etc, not root.
    # This is the directory that you are publishing from (relative to root of your repo)
    publish = "project/build-output/"
    # This will be your default build command
    command = "echo 'default context'"
    # This is where we will look for your lambda functions
    functions = "project/functions/"

    # Set enviroment variable prompts for templates
    [template.environment]
    YOUR_ENV_KEYS_NEEDED = "Enter in the ENV key here"
    # ref https://bit.ly/2wQ1mVk
    incoming-hooks = ["Service-1"]

    # Production context: All deploys from the Production branch set in your site's deploy settings will inherit these settings.
    [context.production]
    publish = "output/"
    command = "make publish"
    environment = { ACCESS_TOKEN = "super secret", NODE_ENV = "8.0.1" }

    # Deploy Preview context: All Deploy Previews (https://www.netlify.com/blog/2016/07/20/introducing-deploy-previews-in-netlify/)
    # will inherit these settings.
    [context.deploy-preview]
    publish = "dist/"
    # Here is another way to define context specific environment variables
    [context.deploy-preview.environment]
    ACCESS_TOKEN = "not so secret"

    # Branch Deploy context: All deploys that are not resulting from a Pull/Merge Request and not from the primary, linked branch will inherit these settings.
    [context.branch-deploy]
    command = "echo branch"
    [context.branch-deploy.environment]
    NODE_ENV = "development"

    # Specific branch context: Deploys from this branch
    # will take these settings and override their
    # current ones.
    [context.staging] # 'staging' is a branch name
    command = "echo 'staging'"
    base = "staging"
    # For contexts of branches with special characters, enclose the branch name with quotes
    [context."feat/branch"]
    command = "echo 'special branch'"
    base = "branch"

    # A basic redirects rule
    [[redirects]]
    from = "/*"
    to = "/blog/:splat"

    # The following show an example redirects rule with all the supported properties.
    [[redirects]]
    from = "/old-path"
    to = "/new-path"
    status = 301
    force = false
    query = {path = ":path"} # apply this rule for /old-path?path=example
    # NOTE: Each combination of query params will need to be defined in a separate [[redirects]] block. More here: https://www.netlify.com/docs/redirects/#query-params
    conditions = {Language = ["en"], Country = ["US"], Role = ["admin"]}
    # you can use env variables you've set in the UI or within your contexts as values
    # sign each request with the value of this env variable
    signed = "API_SIGNATURE_TOKEN"
    # NOTE: env variables are only natively supported for this signed property of headers via this mechanism!
    # You can also define custom headers within your redirects blocks
    [redirects.headers]
    X-From = "Netlify"
    X-Api-Key = "some-api-key-string"

    # The following redirect is intended for use with most SPA's that handles routing internally.
    [[redirects]]
    from = "/*"
    to = "/index.html"
    status = 200

    [[redirects]]
    from = "/api/*"
    to = "https://us-central1-netlify-intercom.cloudfunctions.net/readHeaders/:splat"
    status = 200
    force = true
    conditions = {Role = ["admin", "cms"]}
    [redirects.headers]
    X-From = "Netlify"
    X-Api-Key = "some-api-key-string"

    [[headers]]
    for = "/*" # This defines which paths this specific [[headers]] block will cover.
    [headers.values]
    X-Frame-Options = "DENY"
    X-XSS-Protection = "1; mode=block"
    Content-Security-Policy = "frame-ancestors https://www.facebook.com"
    # Multi-key header rules are expressed with multi-line strings
    Link = '''
    </assets/css/base.css>; rel=preload; as=style, \
    </assets/css/base2.css>; rel=preload; as=style, \
    </assets/css/base3.css>; rel=preload; as=style'''
    # Basic-Auth allows you to password protect your whole site but is only available
    # to paid accounts
    Basic-Auth = "someuser:somepassword anotheruser:anotherpassword"