Skip to content

Commit 0eb01cf

Browse files
committed
feat: Finalize sass/scss/stylus
1 parent 4f53314 commit 0eb01cf

File tree

9 files changed

+107
-21
lines changed

9 files changed

+107
-21
lines changed

generator/index.js

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,22 @@ const iconMap = {
2424
mdi: 'mdi-v4'
2525
}
2626

27-
const components = []
27+
const components = [
28+
'QLayout',
29+
'QHeader',
30+
'QDrawer',
31+
'QPageContainer',
32+
'QPage',
33+
'QToolbar',
34+
'QToolbarTitle',
35+
'QBtn',
36+
'QIcon',
37+
'QList',
38+
'QItem',
39+
'QItemSection',
40+
'QItemLabel'
41+
]
42+
2843
const directives = []
2944
const plugins = []
3045

@@ -43,10 +58,21 @@ module.exports = (api, opts) => {
4358
const deps = {
4459
dependencies,
4560
devDependencies: {
46-
'babel-plugin-transform-imports': '1.5.0',
61+
'babel-plugin-transform-imports': '1.5.0'
62+
}
63+
}
64+
65+
if (opts.quasar.cssPreprocessor === 'styl') {
66+
Object.assign(deps.devDependencies, {
4767
stylus: '^0.54.5',
4868
'stylus-loader': '^3.0.2'
49-
}
69+
})
70+
}
71+
else if (['sass', 'scss'].includes(opts.quasar.cssPreprocessor)) {
72+
Object.assign(deps.devDependencies, {
73+
'node-sass': '^4.13.0',
74+
'sass-loader': '^8.0.0'
75+
})
5076
}
5177

5278
if (opts.quasar.rtlSupport) {
@@ -57,13 +83,13 @@ module.exports = (api, opts) => {
5783

5884
// modify plugin options
5985
extendPluginOptions(api, (pluginOptions, transpileDependencies) => {
60-
pluginOptions.quasar = pluginOptions.quasar || {}
61-
62-
if (opts.quasar.rtlSupport) {
63-
pluginOptions.quasar.rtlSupport = opts.quasar.rtlSupport
64-
}
65-
66-
pluginOptions.quasar.importStrategy = opts.quasar.importStrategy
86+
pluginOptions.quasar = Object.assign(
87+
pluginOptions.quasar || {},
88+
{
89+
importStrategy: opts.quasar.importStrategy,
90+
rtlSupport: opts.quasar.rtlSupport
91+
}
92+
)
6793

6894
transpileDependencies.push('quasar')
6995

@@ -76,6 +102,10 @@ module.exports = (api, opts) => {
76102
api.render('./templates/rtl')
77103
}
78104

105+
if (opts.quasar.cssPreprocessor !== 'none') {
106+
api.render(`./templates/${opts.quasar.cssPreprocessor}`)
107+
}
108+
79109
if (opts.quasar.replaceComponents) {
80110
const extension = hasTS ? 'ts' : 'js',
81111
routerFile = api.resolve(`src/router.${extension}`),
@@ -105,7 +135,12 @@ module.exports = (api, opts) => {
105135
opts.quasar.features.push(opts.quasar.iconSet)
106136
}
107137

108-
lines += `\nimport './styles/quasar.styl'`
138+
if (opts.quasar.cssPreprocessor !== 'none') {
139+
lines += `\nimport './styles/quasar.${opts.quasar.cssPreprocessor}'`
140+
}
141+
else {
142+
lines += `\nimport 'quasar/dist/quasar.css'`
143+
}
109144

110145
if (opts.quasar.features.includes('ie')) {
111146
lines += `\nimport 'quasar/dist/quasar.ie.polyfills'`
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import './quasar.variables.sass'
2+
@import '~quasar-styl'
3+
// @import '~quasar-addon-styl'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// It's highly recommended to change the default colors
2+
// to match your app's branding.
3+
4+
$primary : #027BE3
5+
$secondary : #26A69A
6+
$accent : #9C27B0
7+
8+
$dark : #1D1D1D
9+
10+
$positive : #21BA45
11+
$negative : #C10015
12+
$info : #31CCEC
13+
$warning : #F2C037
14+
15+
@import '~quasar-variables-styl'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import './quasar.variables.scss';
2+
@import '~quasar-styl';
3+
// @import '~quasar-addon-styl';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// It's highly recommended to change the default colors
2+
// to match your app's branding.
3+
4+
$primary : #027BE3;
5+
$secondary : #26A69A;
6+
$accent : #9C27B0;
7+
8+
$dark : #1D1D1D;
9+
10+
$positive : #21BA45;
11+
$negative : #C10015;
12+
$info : #31CCEC;
13+
$warning : #F2C037;
14+
15+
@import '~quasar-variables-styl'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
@import './quasar.variables'
1+
@import './quasar.variables.styl'
22
@import '~quasar-styl'
33
// @import '~quasar-addon-styl'

generator/templates/common/src/styles/quasar.variables.styl renamed to generator/templates/styl/src/styles/quasar.variables.styl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ $primary = #027BE3
55
$secondary = #26A69A
66
$accent = #9C27B0
77

8+
$dark = #1D1D1D
9+
810
$positive = #21BA45
911
$negative = #C10015
1012
$info = #31CCEC

index.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
1+
const fs = require('fs')
12
const path = require('path')
23

4+
function getCssPreprocessor (api) {
5+
return ['sass', 'scss', 'styl'].find(ext => {
6+
return fs.existsSync(
7+
api.resolve('src/styles/quasar.variables.' + ext)
8+
)
9+
})
10+
}
11+
312
module.exports = (api, options) => {
413
if (options.pluginOptions.quasar.rtlSupport) {
514
process.env.QUASAR_RTL = true
615
}
716

17+
const cssPreprocessor = getCssPreprocessor(api)
18+
const srcCssExt = cssPreprocessor === 'scss' ? 'sass' : cssPreprocessor
19+
820
api.chainWebpack(chain => {
9-
chain.resolve.alias
21+
cssPreprocessor && chain.resolve.alias
1022
.set(
1123
'quasar-variables',
12-
api.resolve('src/styles/quasar.variables.styl')
24+
api.resolve(`src/styles/quasar.variables.${cssPreprocessor}`)
1325
)
1426
.set(
1527
'quasar-variables-styl',
16-
'quasar/src/css/variables.styl'
28+
`quasar/src/css/variables.${srcCssExt}`
1729
)
1830
.set(
1931
'quasar-styl',
20-
'quasar/dist/quasar.styl'
32+
`quasar/dist/quasar.${srcCssExt}`
2133
)
2234
.set(
2335
'quasar-addon-styl',
24-
'quasar/src/css/flex-addon.styl'
36+
`quasar/src/css/flex-addon.${srcCssExt}`
2537
)
2638

2739
chain.performance.maxEntrypointSize(512000)

prompts.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ 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 (kebab-case, can be later changed to 'pascal' or 'combined')`,
17+
name: `Auto-import in-use Quasar components & directives (kebab-case, can be later changed to 'pascal'/'combined'/'manual')`,
1818
value: 'kebab',
1919
short: 'Auto import (kebab-case)',
2020
checked: true
@@ -30,7 +30,7 @@ module.exports = [
3030
{
3131
name: 'quasar.cssPreprocessor',
3232
type: 'list',
33-
message: 'Pick your favorite CSS preprocessor: (can be changed later)',
33+
message: 'Pick your favorite CSS preprocessor:',
3434
default: 'sass',
3535
choices: [
3636
{
@@ -45,10 +45,11 @@ module.exports = [
4545
},
4646
{
4747
name: 'Stylus',
48-
value: 'stylus'
48+
value: 'styl',
49+
short: 'Stylus'
4950
},
5051
{
51-
name: 'None (the others will still be available)',
52+
name: `None (style variables won't be available)`,
5253
value: 'none',
5354
short: 'None'
5455
}

0 commit comments

Comments
 (0)