@@ -8,7 +8,18 @@ import routers from './src/routers/'
88
99const pkg = require ( './package' )
1010
11- const isProduction = process . env . BUILD_ENV === 'production'
11+ // const {
12+ // NUXT_ENV_GTM_CONTAINER_ID = '',
13+ // NUXT_ENV_GTM_AUTH = '',
14+ // NUXT_ENV_GTM_PREVIEW = 'env-6',
15+ // NUXT_ENV_GTM_COOKIES_WIN = 'x'
16+ // } = process.env
17+ // Docker から渡ってくるが Nuxt アプリではなく nuxt.config で必要な環境変数
18+ const {
19+ gtmContainerId = 'GTM-56L94CP' ,
20+ gtmPreview = 'env-6' ,
21+ gtmCookiesWin = 'x'
22+ } = process . env
1223
1324const config : NuxtConfiguration = {
1425 mode : 'universal' ,
@@ -19,8 +30,11 @@ const config: NuxtConfiguration = {
1930 * ビルド時に渡される env の値は、ここに記載することで文字列に置換される
2031 */
2132 env : {
33+ // Nuxt のビルドで必要な環境変数
2234 NODE_ENV : process . env . NODE_ENV || '' ,
2335 BUILD_ENV : process . env . BUILD_ENV || '' ,
36+
37+ // Docker から渡ってくる Nuxt アプリで使う環境変数
2438 envName : process . env . envName || '' ,
2539 internalEndpointUrl : process . env . internalEndpointUrl || '' ,
2640 externalEndpointUrl : process . env . externalEndpointUrl || ''
@@ -82,7 +96,7 @@ const config: NuxtConfiguration = {
8296 }
8397 } )
8498 } ,
85- extractCSS : isProduction ,
99+ // extractCSS: isProduction,
86100
87101 // ビルドを爆速にする
88102 // https://qiita.com/toaru/items/0690a9110c94052bb479
@@ -93,7 +107,7 @@ const config: NuxtConfiguration = {
93107 compress : {
94108 // console 系を削除する
95109 // https://www.lancard.com/blog/2019/04/05/delete_console-log_at_nuxt_build/
96- drop_console : process . env . envName === 'production' // eslint-disable-line @typescript-eslint/camelcase
110+ // drop_console: process.env.envName === 'production' // eslint-disable-line @typescript-eslint/camelcase
97111 }
98112 }
99113 }
@@ -166,6 +180,20 @@ const config: NuxtConfiguration = {
166180 // https://github.com/potato4d/nuxt-client-init-module
167181 // https://qiita.com/potato4d/items/cc5d8ea24949e86f8a5b
168182 'nuxt-client-init-module' ,
183+ [
184+ '@nuxtjs/google-tag-manager' ,
185+ {
186+ id : gtmContainerId ,
187+ layer : 'dataLayer' ,
188+ pageTracking : false ,
189+ dev : false ,
190+ query : {
191+ // gtm_auth: NUXT_ENV_GTM_AUTH, // eslint-disable-line @typescript-eslint/camelcase
192+ gtm_preview : gtmPreview , // eslint-disable-line @typescript-eslint/camelcase
193+ gtm_cookies_win : gtmCookiesWin // eslint-disable-line @typescript-eslint/camelcase
194+ }
195+ }
196+ ] ,
169197 // https://github.com/samtgarson/nuxt-env
170198 [
171199 'nuxt-env' ,
0 commit comments