rollup cache for all js bunling, improves subsequent build time by 50%
This commit is contained in:
parent
b1e5db0ec9
commit
fc62af9d5b
12
gulpfile.js
12
gulpfile.js
|
@ -66,13 +66,13 @@ babelConfigESM.presets[0][1].targets = { browsers: [
|
||||||
'last 2 Edge versions', 'not Edge < 16',
|
'last 2 Edge versions', 'not Edge < 16',
|
||||||
] };
|
] };
|
||||||
|
|
||||||
let rollupCache;
|
let cache = {};
|
||||||
|
|
||||||
// Creates a bundle with broad browser support, exposed
|
// Creates a bundle with broad browser support, exposed
|
||||||
// as UMD
|
// as UMD
|
||||||
gulp.task('js-es5', () => {
|
gulp.task('js-es5', () => {
|
||||||
return rollup({
|
return rollup({
|
||||||
cache: rollupCache,
|
cache: cache.umd,
|
||||||
input: 'js/index.js',
|
input: 'js/index.js',
|
||||||
plugins: [
|
plugins: [
|
||||||
resolve(),
|
resolve(),
|
||||||
|
@ -81,7 +81,7 @@ gulp.task('js-es5', () => {
|
||||||
terser()
|
terser()
|
||||||
]
|
]
|
||||||
}).then( bundle => {
|
}).then( bundle => {
|
||||||
rollupCache = bundle.cache;
|
cache.umd = bundle.cache;
|
||||||
return bundle.write({
|
return bundle.write({
|
||||||
name: 'Reveal',
|
name: 'Reveal',
|
||||||
file: './dist/reveal.js',
|
file: './dist/reveal.js',
|
||||||
|
@ -95,7 +95,7 @@ gulp.task('js-es5', () => {
|
||||||
// Creates an ES module bundle
|
// Creates an ES module bundle
|
||||||
gulp.task('js-es6', () => {
|
gulp.task('js-es6', () => {
|
||||||
return rollup({
|
return rollup({
|
||||||
cache: rollupCache,
|
cache: cache.esm,
|
||||||
input: 'js/index.js',
|
input: 'js/index.js',
|
||||||
plugins: [
|
plugins: [
|
||||||
resolve(),
|
resolve(),
|
||||||
|
@ -104,7 +104,7 @@ gulp.task('js-es6', () => {
|
||||||
terser()
|
terser()
|
||||||
]
|
]
|
||||||
}).then( bundle => {
|
}).then( bundle => {
|
||||||
rollupCache = bundle.cache;
|
cache.esm = bundle.cache;
|
||||||
return bundle.write({
|
return bundle.write({
|
||||||
file: './dist/reveal.esm.js',
|
file: './dist/reveal.esm.js',
|
||||||
format: 'es',
|
format: 'es',
|
||||||
|
@ -127,6 +127,7 @@ gulp.task('plugins', () => {
|
||||||
{ name: 'RevealMath', input: './plugin/math/plugin.js', output: './plugin/math/math' },
|
{ name: 'RevealMath', input: './plugin/math/plugin.js', output: './plugin/math/math' },
|
||||||
].map( plugin => {
|
].map( plugin => {
|
||||||
return rollup({
|
return rollup({
|
||||||
|
cache: cache[plugin.input],
|
||||||
input: plugin.input,
|
input: plugin.input,
|
||||||
plugins: [
|
plugins: [
|
||||||
resolve(),
|
resolve(),
|
||||||
|
@ -138,6 +139,7 @@ gulp.task('plugins', () => {
|
||||||
terser()
|
terser()
|
||||||
]
|
]
|
||||||
}).then( bundle => {
|
}).then( bundle => {
|
||||||
|
cache[plugin.input] = bundle.cache;
|
||||||
bundle.write({
|
bundle.write({
|
||||||
file: plugin.output + '.esm.js',
|
file: plugin.output + '.esm.js',
|
||||||
name: plugin.name,
|
name: plugin.name,
|
||||||
|
|
Loading…
Reference in New Issue