1- // https://qiita.com/iwata@github /items/5bc61ea9ca1c692d0370
2- import { Configuration } from 'webpack'
3- import { Context } from '@nuxt/vue-app'
1+ import NuxtConfiguration from '@nuxt/config'
2+ import {
3+ Configuration as WebpackConfiguration ,
4+ Options as WebpackOptions ,
5+ Plugin as WebpackPlugin
6+ } from 'webpack'
47import routers from './src/routers/'
58
69const pkg = require ( './package' )
710
811const isProduction = process . env . BUILD_ENV === 'production'
912
10- module . exports = {
13+ const config : NuxtConfiguration = {
1114 mode : 'universal' ,
1215 srcDir : 'src/' ,
1316
@@ -16,11 +19,11 @@ module.exports = {
1619 * ビルド時に渡される env の値は、ここに記載することで文字列に置換される
1720 */
1821 env : {
19- NODE_ENV : process . env . NODE_ENV ,
20- BUILD_ENV : process . env . BUILD_ENV ,
21- envName : process . env . envName ,
22- internalEndpointUrl : process . env . internalEndpointUrl ,
23- externalEndpointUrl : process . env . externalEndpointUrl
22+ NODE_ENV : process . env . NODE_ENV || '' ,
23+ BUILD_ENV : process . env . BUILD_ENV || '' ,
24+ envName : process . env . envName || '' ,
25+ internalEndpointUrl : process . env . internalEndpointUrl || '' ,
26+ externalEndpointUrl : process . env . externalEndpointUrl || ''
2427 } ,
2528
2629 /**
@@ -31,7 +34,15 @@ module.exports = {
3134 /**
3235 * You can extend webpack config here
3336 */
34- extend ( config : Configuration , ctx : Context ) : void {
37+ extend (
38+ config : WebpackConfiguration ,
39+ ctx : {
40+ isDev : boolean
41+ isClient : boolean
42+ isServer : boolean
43+ loaders : any
44+ }
45+ ) : void {
3546 // Run ESLint on save
3647 if ( ctx . isDev && process . client ) {
3748 if ( config . module ) {
@@ -112,12 +123,12 @@ module.exports = {
112123 * Plugins to load before mounting the App
113124 */
114125 plugins : [
115- '@/plugins/axios.ts' ,
116126 '@/plugins/constants-inject.ts' ,
117127 '@/plugins/env-inject.ts' ,
118- '@/plugins/vue-lazyload.ts' ,
119- '@/plugins/i18n.ts' ,
120- { src : '@/plugins/vue-carousel.ts' , ssr : false }
128+ '@/plugins/libraries/axios.ts' ,
129+ '@/plugins/libraries/vue-lazyload.ts' ,
130+ '@/plugins/locale/i18n.ts' ,
131+ { src : '@/plugins/libraries/vue-carousel.ts' , ssr : false }
121132 ] ,
122133
123134 /*
@@ -190,3 +201,5 @@ module.exports = {
190201 { path : '/api/healthcheck' , handler : '~/api/healthcheck.js' }
191202 ]
192203}
204+
205+ module . exports = config
0 commit comments