mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat(generator): add ignoreEnv generate option during ensureBuild(cmd) (#8955)
[release]
This commit is contained in:
parent
f4a6b38407
commit
b116d0ded4
@ -89,7 +89,14 @@ export async function ensureBuild (cmd) {
|
||||
|
||||
// Quick diff
|
||||
let needBuild = false
|
||||
for (const field of ['nuxtVersion', 'ssr', 'target', 'env', 'process.env']) {
|
||||
|
||||
const fields = ['nuxtVersion', 'ssr', 'target']
|
||||
|
||||
if (nuxt.options.generate.ignoreEnv !== true) {
|
||||
fields.push('env', 'process.env')
|
||||
}
|
||||
|
||||
for (const field of fields) {
|
||||
if (JSON.stringify(previousBuild[field]) !== JSON.stringify(currentBuild[field])) {
|
||||
needBuild = true
|
||||
consola.info(`Doing webpack rebuild because ${field} changed`)
|
||||
|
@ -3,6 +3,7 @@ export default () => ({
|
||||
routes: [],
|
||||
exclude: [],
|
||||
concurrency: 500,
|
||||
ignoreEnv: false,
|
||||
interval: 0,
|
||||
subFolders: true,
|
||||
fallback: '200.html',
|
||||
|
@ -219,6 +219,7 @@ Object {
|
||||
"dir": "/var/nuxt/test/dist",
|
||||
"exclude": Array [],
|
||||
"fallback": "200.html",
|
||||
"ignoreEnv": false,
|
||||
"interval": 0,
|
||||
"manifest": true,
|
||||
"nojekyll": true,
|
||||
|
@ -194,6 +194,7 @@ Object {
|
||||
"dir": "dist",
|
||||
"exclude": Array [],
|
||||
"fallback": "200.html",
|
||||
"ignoreEnv": false,
|
||||
"interval": 0,
|
||||
"manifest": true,
|
||||
"nojekyll": true,
|
||||
@ -583,6 +584,7 @@ Object {
|
||||
"dir": "dist",
|
||||
"exclude": Array [],
|
||||
"fallback": "200.html",
|
||||
"ignoreEnv": false,
|
||||
"interval": 0,
|
||||
"manifest": true,
|
||||
"nojekyll": true,
|
||||
|
1
packages/types/config/generate.d.ts
vendored
1
packages/types/config/generate.d.ts
vendored
@ -17,6 +17,7 @@ export interface NuxtOptionsGenerate {
|
||||
dir?: string
|
||||
exclude?: RegExp[]
|
||||
fallback?: string | boolean
|
||||
ignoreEnv?: boolean
|
||||
interval?: number
|
||||
nojekyll?: boolean
|
||||
routes?: NuxtOptionsGenerateRoute[] | NuxtOptionsGenerateRoutesFunction | NuxtOptionsGenerateRoutesFunctionWithCallback
|
||||
|
3
test/fixtures/full-static-with-ignore-env/full-static-with-ignore-env.test.js
vendored
Normal file
3
test/fixtures/full-static-with-ignore-env/full-static-with-ignore-env.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { buildFixture } from '../../utils/build'
|
||||
|
||||
buildFixture('full-static-with-ignore-env')
|
40
test/fixtures/full-static-with-ignore-env/layouts/default.vue
vendored
Normal file
40
test/fixtures/full-static-with-ignore-env/layouts/default.vue
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<main>
|
||||
<nav>
|
||||
<NLink to="/">
|
||||
Home
|
||||
</NLink>
|
||||
<NLink to="/store">
|
||||
Store
|
||||
</NLink>
|
||||
<NLink to="/encoding/中文">
|
||||
Encoding
|
||||
</NLink>
|
||||
<NLink to="/pagination/1">
|
||||
Pagination
|
||||
</NLink>
|
||||
<NLink to="/dynamic/foo bar/#hash">
|
||||
Dynamic route 1
|
||||
</NLink>
|
||||
<NLink to="/dynamic/foo%20bar">
|
||||
Dynamic route 2
|
||||
</NLink>
|
||||
</nav>
|
||||
<br>
|
||||
<Nuxt />
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
main {
|
||||
margin: 1em 1em;
|
||||
}
|
||||
|
||||
nav {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
a {
|
||||
margin-right: 1em;
|
||||
}
|
||||
</style>
|
30
test/fixtures/full-static-with-ignore-env/nuxt.config.js
vendored
Normal file
30
test/fixtures/full-static-with-ignore-env/nuxt.config.js
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
export default {
|
||||
target: 'static',
|
||||
export: {
|
||||
payload: {
|
||||
config: true
|
||||
}
|
||||
},
|
||||
router: {
|
||||
// base: '/test',
|
||||
},
|
||||
generate: {
|
||||
ignoreEnv: true
|
||||
},
|
||||
foo: {
|
||||
shell: process.env.SHELL
|
||||
},
|
||||
env: {
|
||||
x: 123
|
||||
},
|
||||
hooks: {
|
||||
export: {
|
||||
before ({ setPayload }) {
|
||||
setPayload({ shared: true })
|
||||
},
|
||||
route ({ route, setPayload }) {
|
||||
setPayload({ myRoute: route })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
10
test/fixtures/full-static-with-ignore-env/pages/dynamic/_name.vue
vendored
Normal file
10
test/fixtures/full-static-with-ignore-env/pages/dynamic/_name.vue
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<template>
|
||||
<div>
|
||||
Welcome {{ $route.params.name || 'nuxter' }}!
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
}
|
||||
</script>
|
5
test/fixtures/full-static-with-ignore-env/pages/encoding/中文.vue
vendored
Normal file
5
test/fixtures/full-static-with-ignore-env/pages/encoding/中文.vue
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Encoded path</h1>
|
||||
</div>
|
||||
</template>
|
5
test/fixtures/full-static-with-ignore-env/pages/index.vue
vendored
Normal file
5
test/fixtures/full-static-with-ignore-env/pages/index.vue
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Full Static Playground!</h1>
|
||||
</div>
|
||||
</template>
|
21
test/fixtures/full-static-with-ignore-env/pages/pagination/_i.vue
vendored
Normal file
21
test/fixtures/full-static-with-ignore-env/pages/pagination/_i.vue
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<template>
|
||||
<div>
|
||||
<NLink v-if="i>0" :to="`./${i-1}`">
|
||||
Previous
|
||||
</NLink>
|
||||
Page {{ i }}
|
||||
<NLink v-if="i<5" :to="`./${i+1}`">
|
||||
Next
|
||||
</NLink>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
computed: {
|
||||
i () {
|
||||
return parseInt(this.$route.params.i) || 0
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
13
test/fixtures/full-static-with-ignore-env/pages/payload.vue
vendored
Normal file
13
test/fixtures/full-static-with-ignore-env/pages/payload.vue
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
<template>
|
||||
<div v-text="JSON.stringify(payload)" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
asyncData ({ payload }) {
|
||||
return {
|
||||
payload
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
18
test/fixtures/full-static-with-ignore-env/pages/store.vue
vendored
Normal file
18
test/fixtures/full-static-with-ignore-env/pages/store.vue
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<div>
|
||||
<h3>Welcome {{ $store.state.auth.user.name }}!</h3>
|
||||
<br>
|
||||
You visited this page <strong>{{ $store.state.counter }}</strong> times.
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
async asyncData ({ store }) {
|
||||
await store.dispatch('auth/FETCH_USER')
|
||||
},
|
||||
fetch () {
|
||||
this.$store.commit('COUNT')
|
||||
}
|
||||
}
|
||||
</script>
|
17
test/fixtures/full-static-with-ignore-env/store/auth.js
vendored
Normal file
17
test/fixtures/full-static-with-ignore-env/store/auth.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
export const state = () => ({
|
||||
user: null
|
||||
})
|
||||
|
||||
export const mutations = {
|
||||
SET_USER (state, user) {
|
||||
state.user = user
|
||||
}
|
||||
}
|
||||
|
||||
export const actions = {
|
||||
FETCH_USER ({ commit }) {
|
||||
commit('SET_USER', {
|
||||
name: (process.client ? 'C' : 'S') + ' Æ A-' + (10 + Math.round(Math.random() * 10))
|
||||
})
|
||||
}
|
||||
}
|
9
test/fixtures/full-static-with-ignore-env/store/index.js
vendored
Normal file
9
test/fixtures/full-static-with-ignore-env/store/index.js
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
export const state = () => ({
|
||||
counter: 0
|
||||
})
|
||||
|
||||
export const mutations = {
|
||||
COUNT (state) {
|
||||
state.counter += 1
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user