saleor / saleor-storefront

A GraphQL-powered, NextJs-based, PWA storefront for Saleor. IMPORTANT: This project is [DEPRECATED] in favor of saleor/react-storefront soon to become our default demo and storefront starter pack.
https://demo.saleor.io/
BSD 3-Clause "New" or "Revised" License
769 stars 672 forks source link

Build error when adding GTM_ID build arg #1011

Open null-ref-0000 opened 3 years ago

null-ref-0000 commented 3 years ago

What I'm trying to achieve

On 3.0.0-a.5 I am attempting to include a GTM_ID when building a docker image.

Steps to reproduce the problem

  1. docker build --build-arg GTM_ID=GTM-????? .

What I expected to happen

Docker image is built and GTM_ID is added to project.

Error

> Build error occurred
ReferenceError: document is not defined
    at Object.dataScript (/app/node_modules/react-gtm-module/dist/TagManager.js:11:18)
    at Object.gtm (/app/node_modules/react-gtm-module/dist/TagManager.js:30:27)
    at Object.initialize (/app/node_modules/react-gtm-module/dist/TagManager.js:50:20)
    at Module.hUgY (/app/.next/server/pages/_app.js:20487:39)
    at __webpack_require__ (/app/.next/server/pages/_app.js:23:31)
    at Object.1 (/app/.next/server/pages/_app.js:243:18)
    at __webpack_require__ (/app/.next/server/pages/_app.js:23:31)
    at /app/.next/server/pages/_app.js:91:18
    at Object.<anonymous> (/app/.next/server/pages/_app.js:94:10)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at hasCustomGetInitialProps (/app/node_modules/next/dist/build/utils.js:26:1231)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! saleor-site@3.0.0-a.5 build: `next build`
npm ERR! Exit status 1

System information Operating system: Linux

null-ref-0000 commented 3 years ago

Any suggestions on how to fix this bug?