Skip to content

Commit e9ae442

Browse files
committed
chore: Build updates
1 parent 4a47a79 commit e9ae442

File tree

2 files changed

+45
-36
lines changed

2 files changed

+45
-36
lines changed

build/script.build.javascript.js

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,53 @@ const
2020
const builds = [
2121
{
2222
rollup: {
23-
input: resolve(`src/index.esm.js`),
23+
input: {
24+
input: resolve(`src/index.esm.js`)
25+
},
2426
output: {
2527
file: resolve(`dist/quasar.${buildConf.themeToken}.esm.js`),
2628
format: 'es'
2729
}
2830
},
29-
meta: { buildUnminified: true }
31+
build: { unminified: true }
3032
},
3133
{
3234
rollup: {
33-
input: resolve('src/ie-compat/ie.js'),
35+
input: {
36+
input: resolve('src/ie-compat/ie.js')
37+
},
3438
output: {
3539
file: resolve('dist/quasar.ie.polyfills.js'),
3640
format: 'es'
3741
}
3842
},
39-
meta: { buildUnminified: true }
43+
build: { unminified: true }
4044
},
4145
{
4246
rollup: {
43-
input: resolve('src/ie-compat/ie.js'),
47+
input: {
48+
input: resolve('src/ie-compat/ie.js')
49+
},
4450
output: {
4551
file: resolve('dist/umd/quasar.ie.polyfills.umd.js'),
4652
format: 'umd'
4753
}
4854
},
49-
meta: { buildMinified: true }
55+
build: { minified: true }
5056
},
5157
{
5258
rollup: {
53-
input: resolve(`src/index.umd.js`),
59+
input: {
60+
input: resolve(`src/index.umd.js`)
61+
},
5462
output: {
5563
file: resolve(`dist/umd/quasar.${buildConf.themeToken}.umd.js`),
5664
format: 'umd'
5765
}
5866
},
59-
meta: {
60-
buildUnminified: true,
61-
buildMinified: true
67+
build: {
68+
unminified: true,
69+
minified: true
6270
}
6371
}
6472
]
@@ -76,30 +84,27 @@ function resolve (_path) {
7684
return path.resolve(__dirname, '..', _path)
7785
}
7886

79-
function camel (str) {
80-
return str.charAt(0).toUpperCase() + str.substr(1)
81-
}
82-
8387
function addAssets (builds, type) {
8488
const
8589
files = fs.readdirSync(resolve(type)),
86-
plugins = [ buble() ],
87-
camelType = camel(type)
90+
plugins = [ buble() ]
8891

8992
files.forEach(file => {
90-
const name = file.replace(/-([a-z])/g, g => g[1].toUpperCase())
93+
const name = file.substr(0, file.length - 3).replace(/-([a-z])/g, g => g[1].toUpperCase())
9194
builds.push({
9295
rollup: {
93-
input: resolve(`${type}/${file}`),
96+
input: {
97+
input: resolve(`${type}/${file}`),
98+
plugins
99+
},
94100
output: {
95101
file: addExtension(resolve(`dist/umd/${type}.${file}`), 'umd'),
96102
format: 'umd',
97-
name: `Quasar${camelType}${camel(name)}`
98-
},
99-
plugins
103+
name: `Quasar.${type}.${name}`
104+
}
100105
},
101-
meta: {
102-
buildMinified: true
106+
build: {
107+
minified: true
103108
}
104109
})
105110
})
@@ -117,7 +122,7 @@ function processEntries (entries) {
117122
buildConf.themes.forEach(theme => {
118123
const clone = JSON.parse(JSON.stringify(entry))
119124
clone.rollup.output.file = entry.rollup.output.file.replace(buildConf.themeToken, theme)
120-
clone.meta.theme = theme
125+
clone.build.theme = theme
121126
builds.push(clone)
122127
})
123128
})
@@ -132,11 +137,11 @@ function build (builds) {
132137
}
133138

134139
function genConfig (opts) {
135-
const theme = opts.meta && opts.meta.theme
136-
? opts.meta.theme
140+
const theme = opts.build && opts.build.theme
141+
? opts.build.theme
137142
: null
138143

139-
const plugins = opts.meta.plugins || [
144+
const plugins = opts.rollup.input.plugins || [
140145
nodeResolve({
141146
extensions: theme
142147
? [`.${theme}.js`, '.js', `.${theme}.vue`, '.vue']
@@ -156,16 +161,16 @@ function genConfig (opts) {
156161
)
157162
}
158163

164+
opts.rollup.input.plugins = plugins
159165
opts.rollup.output.banner = buildConf.banner
160166
opts.rollup.output.name = opts.rollup.output.name || 'Quasar'
161-
opts.rollup.plugins = plugins
162167

163168
if (opts.rollup.output.format === 'umd') {
169+
opts.rollup.input.external = opts.rollup.input.external || []
170+
opts.rollup.input.external.push('vue')
171+
164172
opts.rollup.output.globals = opts.rollup.output.globals || {}
165173
opts.rollup.output.globals.vue = 'Vue'
166-
167-
opts.rollup.external = opts.rollup.external || []
168-
opts.rollup.external.push('vue')
169174
}
170175

171176
return opts
@@ -178,15 +183,15 @@ function addExtension (filename, ext = 'min') {
178183

179184
function buildEntry (config) {
180185
return rollup
181-
.rollup(config.rollup)
182-
.then(bundle => bundle.generate(config.rollup))
186+
.rollup(config.rollup.input)
187+
.then(bundle => bundle.generate(config.rollup.output))
183188
.then(({ code }) => {
184-
return config.meta.buildUnminified
189+
return config.build.unminified
185190
? buildUtils.writeFile(config.rollup.output.file, code)
186191
: code
187192
})
188193
.then(code => {
189-
if (!config.meta.buildMinified) {
194+
if (!config.build.minified) {
190195
return code
191196
}
192197

@@ -202,7 +207,7 @@ function buildEntry (config) {
202207

203208
return buildUtils.writeFile(
204209
addExtension(config.rollup.output.file),
205-
(config.rollup.output.banner || '') + minified.code,
210+
buildConf.banner + minified.code,
206211
true
207212
)
208213
})

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@
104104
"peerDependencies": {
105105
"vue": "^2.5.0"
106106
},
107+
"engines": {
108+
"node": ">= 8.9.0",
109+
"npm": ">= 5.6.0"
110+
},
107111
"browserslist": [
108112
"> 1%",
109113
"last 2 versions",

0 commit comments

Comments
 (0)