diff --git a/packages/builder/src/context/template.js b/packages/builder/src/context/template.js index b63fa5e830..a330d94f89 100644 --- a/packages/builder/src/context/template.js +++ b/packages/builder/src/context/template.js @@ -20,6 +20,7 @@ export default class TemplateContext { isDev: options.dev, isTest: options.test, debug: options.debug, + buildIndicator: options.dev && options.build.indicator, vue: { config: options.vue.config }, fetch: options.fetch, mode: options.mode, diff --git a/packages/builder/test/context/__snapshots__/template.test.js.snap b/packages/builder/test/context/__snapshots__/template.test.js.snap index ed72014bea..b40a5fddbc 100644 --- a/packages/builder/test/context/__snapshots__/template.test.js.snap +++ b/packages/builder/test/context/__snapshots__/template.test.js.snap @@ -7,6 +7,7 @@ TemplateContext { ], "templateVars": Object { "appPath": "./App.js", + "buildIndicator": undefined, "components": Object { "ErrorPage": "relativeBuild(test_error_page)", }, diff --git a/packages/config/src/config/build.js b/packages/config/src/config/build.js index e0f8a282bc..861258cf66 100644 --- a/packages/config/src/config/build.js +++ b/packages/config/src/config/build.js @@ -3,6 +3,7 @@ import env from 'std-env' export default () => ({ quiet: Boolean(env.ci || env.test), analyze: false, + indicator: true, profile: process.argv.includes('--profile'), extractCSS: false, crossorigin: undefined, diff --git a/packages/config/test/__snapshots__/options.test.js.snap b/packages/config/test/__snapshots__/options.test.js.snap index 66e8e22aac..0f082de04a 100644 --- a/packages/config/test/__snapshots__/options.test.js.snap +++ b/packages/config/test/__snapshots__/options.test.js.snap @@ -54,6 +54,7 @@ Object { "useShortDoctype": true, }, }, + "indicator": true, "loaders": Object { "css": Object { "sourceMap": false, diff --git a/packages/config/test/config/__snapshots__/index.test.js.snap b/packages/config/test/config/__snapshots__/index.test.js.snap index 945498ea59..cf73a8b009 100644 --- a/packages/config/test/config/__snapshots__/index.test.js.snap +++ b/packages/config/test/config/__snapshots__/index.test.js.snap @@ -41,6 +41,7 @@ Object { "useShortDoctype": true, }, }, + "indicator": true, "loaders": Object { "css": Object {}, "cssModules": Object { @@ -374,6 +375,7 @@ Object { "useShortDoctype": true, }, }, + "indicator": true, "loaders": Object { "css": Object {}, "cssModules": Object { diff --git a/packages/config/types/build.d.ts b/packages/config/types/build.d.ts index 7c260a1b00..0c82c14246 100644 --- a/packages/config/types/build.d.ts +++ b/packages/config/types/build.d.ts @@ -49,6 +49,7 @@ export interface NuxtConfigurationBuild { hardSource?: boolean hotMiddleware?: WebpackHotMiddlewareOptions html?: { minify: HtmlMinifierOptions } + indicator?: boolean loaders?: NuxtConfigurationLoaders optimization?: WebpackOptions.Optimization optimizeCSS?: OptimizeCssAssetsWebpackPluginOptions | boolean diff --git a/packages/vue-app/src/index.js b/packages/vue-app/src/index.js index aa4160c958..6da9555fc2 100644 --- a/packages/vue-app/src/index.js +++ b/packages/vue-app/src/index.js @@ -13,6 +13,7 @@ export const template = { 'server.js', 'utils.js', 'empty.js', + 'components/nuxt-build-indicator.vue', 'components/nuxt-error.vue', 'components/nuxt-loading.vue', 'components/nuxt-child.js', diff --git a/packages/vue-app/template/App.js b/packages/vue-app/template/App.js index 4b362a4600..73786fbc28 100644 --- a/packages/vue-app/template/App.js +++ b/packages/vue-app/template/App.js @@ -1,5 +1,6 @@ import Vue from 'vue' <% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.vue") %>'<% } %> +<%if (buildIndicator) { %>import NuxtBuildIndicator from './components/nuxt-build-indicator'<% } %> <% css.forEach((c) => { %> import '<%= relativeToBuild(resolvePath(c.src || c, { isStyle: true })) %>' <% }) %> @@ -49,10 +50,7 @@ export default { domProps: { id: '<%= globals.id %>' } - }, [ - <% if (loading) { %>loadingEl,<% } %> - transitionEl - ]) + }, [<% if (loading) { %>loadingEl, <% } %><%if (buildIndicator) { %>h(NuxtBuildIndicator), <% } %>transitionEl]) }, data: () => ({ isOnline: true, diff --git a/packages/vue-app/template/components/nuxt-build-indicator.vue b/packages/vue-app/template/components/nuxt-build-indicator.vue new file mode 100644 index 0000000000..b3dee69944 --- /dev/null +++ b/packages/vue-app/template/components/nuxt-build-indicator.vue @@ -0,0 +1,155 @@ + + + + +