From 8ae091d3d7724e3fc6a9af3f44f536024459de47 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Mon, 8 Apr 2019 21:32:01 +0430 Subject: [PATCH 1/4] feat(nuxt): add `pretranspile` option --- nuxt/index.js | 12 ++++++++++-- nuxt/plugin.template.js | 8 ++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/nuxt/index.js b/nuxt/index.js index 735e7233a07..c08f180594b 100644 --- a/nuxt/index.js +++ b/nuxt/index.js @@ -47,10 +47,18 @@ module.exports = function nuxtBootstrapVue(moduleOptions = {}) { this.options.css.unshift('bootstrap/dist/css/bootstrap.css') } - // Transpile src + // Transpile src/ this.options.build.transpile.push('bootstrap-vue/src') - const templateOptions = {} + // Use es/ or src/ + const pretranspile = pickFirst( + options.pretranspile, + this.options.dev + ) + + const templateOptions = { + dist: pretranspile ? 'es' : 'src' + } // TODO: Also add support for individual components & directives for (const type of ['componentPlugins', 'directivePlugins']) { diff --git a/nuxt/plugin.template.js b/nuxt/plugin.template.js index 4b5b4123f51..db2a857fae9 100644 --- a/nuxt/plugin.template.js +++ b/nuxt/plugin.template.js @@ -1,10 +1,10 @@ import Vue from 'vue' <% if (options.componentPlugins.length || options.directivePlugins.length) { %><%= -options.componentPlugins.reduce((acc, p) => (acc += `import ${p[0]} from 'bootstrap-vue/es/components/${p[1]}'\n` ), '') %><%= -options.directivePlugins.reduce((acc, p) => (acc += `import ${p[0]} from 'bootstrap-vue/es/directives/${p[1]}'\n` ), '') %> +options.componentPlugins.reduce((acc, p) => (acc += `import ${p[0]} from 'bootstrap-vue/${options.dist}/components/${p[1]}'\n` ), '') %><%= +options.directivePlugins.reduce((acc, p) => (acc += `import ${p[0]} from 'bootstrap-vue/${options.dist}/directives/${p[1]}'\n` ), '') %> <% if (options.config) { %> -import BVConfigPlugin from 'bootstrap-vue/es/bv-config' +import BVConfigPlugin from 'bootstrap-vue/<%= options.dist %>/bv-config' Vue.use(BVConfigPlugin, <%= JSON.stringify(options.config, undefined, 2) %>) <% } %> @@ -13,7 +13,7 @@ Vue.use(BVConfigPlugin, <%= JSON.stringify(options.config, undefined, 2) %>) options.componentPlugins.reduce((acc, p) => (acc += `Vue.use(${p[0]})\n` ), '') %><%= options.directivePlugins.reduce((acc, p) => (acc += `Vue.use(${p[0]})\n` ), '') %> <% } else { %> -import BootstrapVue from 'bootstrap-vue/es' +import BootstrapVue from 'bootstrap-vue/<%= options.dist %>' Vue.use(BootstrapVue, <%= JSON.stringify(options.config || {}, undefined, 2) %>) <% } %> From 4e66107b0e384c82aebf8e6b42acdcc1c402f8d5 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Mon, 8 Apr 2019 21:50:26 +0430 Subject: [PATCH 2/4] fix lint error --- nuxt/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nuxt/index.js b/nuxt/index.js index c08f180594b..ee986a9a32e 100644 --- a/nuxt/index.js +++ b/nuxt/index.js @@ -51,10 +51,7 @@ module.exports = function nuxtBootstrapVue(moduleOptions = {}) { this.options.build.transpile.push('bootstrap-vue/src') // Use es/ or src/ - const pretranspile = pickFirst( - options.pretranspile, - this.options.dev - ) + const pretranspile = pickFirst(options.pretranspile, this.options.dev) const templateOptions = { dist: pretranspile ? 'es' : 'src' From 2785a90d7d079a74ad19c2ffb561210238a39ae1 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Mon, 8 Apr 2019 21:56:21 +0430 Subject: [PATCH 3/4] add docs and rename to usePretranspiled --- docs/markdown/intro/README.md | 9 ++++++++- nuxt/index.js | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/markdown/intro/README.md b/docs/markdown/intro/README.md index d9e0fffa634..a0bf66ffb32 100644 --- a/docs/markdown/intro/README.md +++ b/docs/markdown/intro/README.md @@ -56,7 +56,7 @@ _after_ Bootstrap SCSS to ensure variables are set up correctly. **Note**: _Requires webpack configuration to load CSS/SCSS files ([official guide](https://webpack.js.org/guides/asset-management/#loading-css))_. -## Nuxt.js plugin module +## Nuxt.js Module [Nuxt.js](https://nuxtjs.org) version {{ nuxtVersion }} (or greater) is recommended. @@ -153,6 +153,13 @@ module.exports = { } ``` +### Using pretranspiled version of BootstrapVue for Nuxt.js + +Nuxt module uses precompiled version of BootstrapVue for faster development builds and source of +BootstrapVue for higher quality production builds. + +You can override this option using `usePretranspiled` option. Setting to `true` uses `es/` instead of `src/`. By default is enabled for development mode only. + ## Vue CLI 2 BootstrapVue has two Vue CLI templates available: diff --git a/nuxt/index.js b/nuxt/index.js index ee986a9a32e..db9fd311f78 100644 --- a/nuxt/index.js +++ b/nuxt/index.js @@ -51,10 +51,10 @@ module.exports = function nuxtBootstrapVue(moduleOptions = {}) { this.options.build.transpile.push('bootstrap-vue/src') // Use es/ or src/ - const pretranspile = pickFirst(options.pretranspile, this.options.dev) + const usePretranspiled = pickFirst(options.usePretranspiled, this.options.dev) const templateOptions = { - dist: pretranspile ? 'es' : 'src' + dist: usePretranspiled ? 'es' : 'src' } // TODO: Also add support for individual components & directives From 384e8fd3787a1923203aebb12c4d74242224ee99 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Mon, 8 Apr 2019 14:28:45 -0300 Subject: [PATCH 4/4] Update README.md break long line --- docs/markdown/intro/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/markdown/intro/README.md b/docs/markdown/intro/README.md index a0bf66ffb32..919ea6aea4a 100644 --- a/docs/markdown/intro/README.md +++ b/docs/markdown/intro/README.md @@ -158,7 +158,8 @@ module.exports = { Nuxt module uses precompiled version of BootstrapVue for faster development builds and source of BootstrapVue for higher quality production builds. -You can override this option using `usePretranspiled` option. Setting to `true` uses `es/` instead of `src/`. By default is enabled for development mode only. +You can override this option using `usePretranspiled` option. Setting to `true` uses `es/` instead +of `src/`. By default is enabled for development mode only. ## Vue CLI 2