Skip to content

Commit 028ade2

Browse files
Resul AvanResul Avan
Resul Avan
authored and
Resul Avan
committed
nuxt.config.ts refactoring, add now configuration
1 parent 9029806 commit 028ade2

File tree

4 files changed

+57
-20
lines changed

4 files changed

+57
-20
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737

3838
# nuxt-typescript-ssr-firebase-auth
3939

40-
`nuxt generate` is really sucks!!! We lost `nuxtServerInit`, dynamic routing stuff etc. We need a good alternative to deploy our applications to cloud without VPS and SSL configuration.
40+
`nuxt generate` is really sucks!!! We lost `nuxtServerInit`, dynamic routing stuff etc. We need a good alternative to deploy our applications to the cloud without VPS and SSL configuration.
4141

42-
This repository is created as a sample of using nuxt on firebase-functions+firebase-hosting and still SSR and has `nuxtServerInit` functionally is active.
42+
This repository is created as a sample of using nuxt on firebase-functions+firebase-hosting and still SSR and has the `nuxtServerInit` functionality as active.
4343

4444
Firebase full password authentication (register, login, forget password, reset password), google authentication, twitter authentication, facebook authentication in `nuxt`.
4545

now.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": 2,
3+
"builds": [
4+
{
5+
"src": "nuxt.config.js",
6+
"use": "@nuxtjs/now-builder",
7+
"config": {}
8+
}
9+
]
10+
}

src/components/image/upload/SingleFileUpload.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
</template>
1010

1111
<script lang="ts">
12-
import { Component, Prop, Vue, Watch } from 'nuxt-property-decorator';
13-
import { getNewFileName } from "~/service/global-service";
14-
import { storage, TaskEvent, TaskState } from "~/plugins/fire-init-plugin";
15-
import { handleError } from "~/service/error-service";
12+
import { Component, Prop, Vue, Watch } from 'nuxt-property-decorator'
13+
import { getNewFileName } from '~/service/global-service'
14+
import { storage, TaskEvent, TaskState } from '~/plugins/fire-init-plugin'
15+
import { handleError } from '~/service/error-service'
1616
1717
@Component({
1818
components: {}

src/nuxt.config.ts

+41-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { Configuration } from '@nuxt/types'
2+
13
require('dotenv').config({ path: '.env' })
24

3-
export default {
5+
// export default {
6+
const config: Configuration = {
47
mode: 'universal',
58
/*
69
** Headers of the page
@@ -39,15 +42,15 @@ export default {
3942
*/
4043
css: [],
4144
env: {
42-
WEBSITE_URL: process.env.WEBSITE_URL,
43-
FIREBASE_API_KEY: process.env.FIREBASE_API_KEY,
44-
FIREBASE_AUTH_DOMAIN: process.env.FIREBASE_AUTH_DOMAIN,
45-
FIREBASE_DATABASE_URL: process.env.FIREBASE_DATABASE_URL,
46-
FIREBASE_PROJECT_ID: process.env.FIREBASE_PROJECT_ID,
47-
FIREBASE_STORAGE_BUCKET: process.env.FIREBASE_STORAGE_BUCKET,
48-
FIREBASE_MESSAGING_SENDER_ID: process.env.FIREBASE_MESSAGING_SENDER_ID,
49-
FIREBASE_APP_ID: process.env.FIREBASE_APP_ID,
50-
FIREBASE_MEASUREMENT_ID: process.env.FIREBASE_MEASUREMENT_ID
45+
WEBSITE_URL: process.env.WEBSITE_URL as string,
46+
FIREBASE_API_KEY: process.env.FIREBASE_API_KEY as string,
47+
FIREBASE_AUTH_DOMAIN: process.env.FIREBASE_AUTH_DOMAIN as string,
48+
FIREBASE_DATABASE_URL: process.env.FIREBASE_DATABASE_URL as string,
49+
FIREBASE_PROJECT_ID: process.env.FIREBASE_PROJECT_ID as string,
50+
FIREBASE_STORAGE_BUCKET: process.env.FIREBASE_STORAGE_BUCKET as string,
51+
FIREBASE_MESSAGING_SENDER_ID: process.env.FIREBASE_MESSAGING_SENDER_ID as string,
52+
FIREBASE_APP_ID: process.env.FIREBASE_APP_ID as string,
53+
FIREBASE_MEASUREMENT_ID: process.env.FIREBASE_MEASUREMENT_ID as string
5154
},
5255
/*
5356
** Plugins to load before mounting the App
@@ -132,9 +135,24 @@ export default {
132135
build: {
133136
analyze: false, // env variables are strings
134137
publicPath: '/assets/',
135-
extractCSS: false,
138+
extractCSS: true,
139+
optimization: {
140+
splitChunks: {
141+
cacheGroups: {
142+
styles: {
143+
name: 'styles',
144+
test: /\.(css|vue)$/,
145+
chunks: 'all',
146+
enforce: true
147+
}
148+
}
149+
}
150+
},
151+
filenames: {
152+
chunk: ({ isDev }) => isDev ? '[name].js' : '[id].[contenthash].js'
153+
},
136154
babel: {
137-
presets({ isServer }: any) {
155+
presets({ isServer }) {
138156
return [
139157
[
140158
require.resolve('@nuxt/babel-preset-app'),
@@ -147,7 +165,16 @@ export default {
147165
]
148166
}
149167
},
150-
transpile: ['vee-validate/dist/rules']
168+
transpile: ['vee-validate/dist/rules'],
169+
extend: ({ module }, {}) => {
170+
module?.rules.push(
171+
{
172+
test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
173+
loader: 'file-loader'
174+
}
175+
)
176+
}
151177
},
152-
generate: {}
153178
}
179+
180+
export default config

0 commit comments

Comments
 (0)