Skip to content

Commit 3d89947

Browse files
committed
feat: Finalize auto-import feature
1 parent 7656fc2 commit 3d89947

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const path = require('path')
2+
13
module.exports = (api, options) => {
24
if (options.pluginOptions.quasar.rtlSupport) {
35
process.env.QUASAR_RTL = true
@@ -23,5 +25,15 @@ module.exports = (api, options) => {
2325
)
2426

2527
chain.performance.maxEntrypointSize(512000)
28+
29+
const strategy = options.pluginOptions.quasar.importStrategy
30+
31+
if (['kebab', 'pascal', 'combined'].includes(strategy)) {
32+
chain.module.rule('vue')
33+
.use('quasar-auto-import')
34+
.loader(path.join(__dirname, 'lib/loader.auto-import.js'))
35+
.options(strategy)
36+
.before('cache-loader')
37+
}
2638
})
2739
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
const getDevlandFile = require('../helpers/get-devland-file')
1+
function getDevlandFile (name) {
2+
return require(
3+
require.resolve(name, {
4+
paths: [ __dirname ]
5+
})
6+
)
7+
}
28

39
const data = getDevlandFile('quasar/dist/babel-transforms/auto-import.json')
410

prompts.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ module.exports = [
1414
message: 'Pick a Quasar components & directives import strategy: (can be changed later)',
1515
choices: [
1616
{
17-
name: '* Auto-import in-use Quasar components & directives\n - slightly higher compile time; next to minimum bundle size; most convenient',
18-
value: '\'auto\'',
19-
short: 'Auto import',
17+
name: '* Auto-import in-use Quasar components & directives (kebab-case, can be later changed to \'pascal\' or \'combined\')',
18+
value: 'kebab',
19+
short: 'Auto import (kebab-case)',
2020
checked: true
2121
},
2222
{
23-
name: '* Manually specify what to import\n - fastest compile time; minimum bundle size; most tedious',
23+
name: '* Manually specify what to import',
2424
value: '\'manual\'',
2525
short: 'Manual'
2626
}

0 commit comments

Comments
 (0)