Skip to content

Commit 8022481

Browse files
pi0tmorehouse
authored andcommitted
feat(nuxt): add usePretranspiled option (#3048)
1 parent 4e981c2 commit 8022481

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

docs/markdown/intro/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ _after_ Bootstrap SCSS to ensure variables are set up correctly.
5656
**Note**: _Requires webpack configuration to load CSS/SCSS files
5757
([official guide](https://webpack.js.org/guides/asset-management/#loading-css))_.
5858

59-
## Nuxt.js plugin module
59+
## Nuxt.js Module
6060

6161
[Nuxt.js](https://nuxtjs.org) version {{ nuxtVersion }} (or greater) is recommended.
6262

@@ -153,6 +153,14 @@ module.exports = {
153153
}
154154
```
155155

156+
### Using pretranspiled version of BootstrapVue for Nuxt.js
157+
158+
Nuxt module uses precompiled version of BootstrapVue for faster development builds and source of
159+
BootstrapVue for higher quality production builds.
160+
161+
You can override this option using `usePretranspiled` option. Setting to `true` uses `es/` instead
162+
of `src/`. By default is enabled for development mode only.
163+
156164
## Vue CLI 2
157165

158166
BootstrapVue has two Vue CLI templates available:

nuxt/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ module.exports = function nuxtBootstrapVue(moduleOptions = {}) {
4747
this.options.css.unshift('bootstrap/dist/css/bootstrap.css')
4848
}
4949

50-
// Transpile src
50+
// Transpile src/
5151
this.options.build.transpile.push('bootstrap-vue/src')
5252

53-
const templateOptions = {}
53+
// Use es/ or src/
54+
const usePretranspiled = pickFirst(options.usePretranspiled, this.options.dev)
55+
56+
const templateOptions = {
57+
dist: usePretranspiled ? 'es' : 'src'
58+
}
5459

5560
// TODO: Also add support for individual components & directives
5661
for (const type of ['componentPlugins', 'directivePlugins']) {

nuxt/plugin.template.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import Vue from 'vue'
22
<% if (options.componentPlugins.length || options.directivePlugins.length) { %><%=
3-
options.componentPlugins.reduce((acc, p) => (acc += `import ${p[0]} from 'bootstrap-vue/es/components/${p[1]}'\n` ), '') %><%=
4-
options.directivePlugins.reduce((acc, p) => (acc += `import ${p[0]} from 'bootstrap-vue/es/directives/${p[1]}'\n` ), '') %>
3+
options.componentPlugins.reduce((acc, p) => (acc += `import ${p[0]} from 'bootstrap-vue/${options.dist}/components/${p[1]}'\n` ), '') %><%=
4+
options.directivePlugins.reduce((acc, p) => (acc += `import ${p[0]} from 'bootstrap-vue/${options.dist}/directives/${p[1]}'\n` ), '') %>
55

66
<% if (options.config) { %>
7-
import BVConfigPlugin from 'bootstrap-vue/es/bv-config'
7+
import BVConfigPlugin from 'bootstrap-vue/<%= options.dist %>/bv-config'
88

99
Vue.use(BVConfigPlugin, <%= JSON.stringify(options.config, undefined, 2) %>)
1010
<% } %>
@@ -13,7 +13,7 @@ Vue.use(BVConfigPlugin, <%= JSON.stringify(options.config, undefined, 2) %>)
1313
options.componentPlugins.reduce((acc, p) => (acc += `Vue.use(${p[0]})\n` ), '') %><%=
1414
options.directivePlugins.reduce((acc, p) => (acc += `Vue.use(${p[0]})\n` ), '') %>
1515
<% } else { %>
16-
import BootstrapVue from 'bootstrap-vue/es'
16+
import BootstrapVue from 'bootstrap-vue/<%= options.dist %>'
1717

1818
Vue.use(BootstrapVue, <%= JSON.stringify(options.config || {}, undefined, 2) %>)
1919
<% } %>

0 commit comments

Comments
 (0)