我确实有一个Nuxt应用程序,在这个应用程序中,我从商店内nuxtServerInit()中的API中提取内容。
但是,如果我确实生成了设置nuxt.config.js,中的目标的静态版本:在页面中内容不是预先呈现的“静态”,而我将其设置为“通用”,那么它们就是。
如果你想完全静态的话,“静态”不是正确的设置吗?
这是我的nuxt.config.js文件
// import colors from 'vuetify/es5/util/colors'
export default {
// Global page headers: https://go.nuxtjs.dev/config-head
// target: process.env.NODE_TARGET === 'static' ? 'static' : 'server',
// ssr: true,
target: 'universal',
router: {
base: '/wip/roboat-website/roboat-frontend/dist',
routeNameSplitter: '/'
},
server: {
host: "localhost" // default: localhost
},
head: {
titleTemplate: '%s - roboat-frontend',
title: 'roboat-frontend',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
'~/assets/css/custom.css'
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/typescript
'@nuxt/typescript-build',
// https://go.nuxtjs.dev/vuetify
['@nuxtjs/vuetify', { treeShake: true }]
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/axios
'@nuxtjs/axios',
// https://go.nuxtjs.dev/pwa
'@nuxtjs/pwa',
],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {},
env: {
NUXT_ENV_API_HOST: process.env.NUXT_ENV_API_HOST,
},
// PWA module configuration: https://go.nuxtjs.dev/pwa
pwa: {
manifest: {
lang: 'en'
}
},
// Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
vuetify: {
optionsPath: './vuetify.options.js',
customVariables: ['~/assets/variables.scss'],
treeShake: true,
// defaultAssets: false,
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
html: {
minify: {
collapseBooleanAttributes: true,
decodeEntities: true,
minifyCSS: true,
minifyJS: true,
processConditionalComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
trimCustomFragments: true,
useShortDoctype: true,
minifyURLs: true,
removeComments: true,
removeEmptyElements: true
}
},
// analyze: true,
optimizeCSS:true,
extractCSS: true,
babel: {
plugins: [
["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
]
},
extend(config, { isDev, isClient }) {
// ..
// if (isClient) {
config.module.rules.push({
test: /\.(obj|mtl|fbx|gltf|glb|hdr|bin)$/,
loader: 'file-loader'
})
},
transpile: [
"three"
]
},
}发布于 2021-09-01 13:53:30
看起来,在最后,OP确实有一个与target: 'static'和ssr: true一起工作的代码。
这似乎是合法的,因为这是推荐的(和最新的)做事方式:How to setup Nuxt for an isomorphic universal app?
https://stackoverflow.com/questions/69012988
复制相似问题