switch to rollup for easier build config
This commit is contained in:
parent
0c8ac8f1ee
commit
d54353c4e1
9
dist/plugin/highlight.js
vendored
9
dist/plugin/highlight.js
vendored
File diff suppressed because one or more lines are too long
7
dist/plugin/markdown.js
vendored
7
dist/plugin/markdown.js
vendored
File diff suppressed because one or more lines are too long
2
dist/plugin/math.js
vendored
2
dist/plugin/math.js
vendored
File diff suppressed because one or more lines are too long
2
dist/plugin/notes.js
vendored
2
dist/plugin/notes.js
vendored
File diff suppressed because one or more lines are too long
2
dist/plugin/search.js
vendored
2
dist/plugin/search.js
vendored
File diff suppressed because one or more lines are too long
18
dist/plugin/zoom.js
vendored
18
dist/plugin/zoom.js
vendored
File diff suppressed because one or more lines are too long
4
dist/reveal.css
vendored
4
dist/reveal.css
vendored
File diff suppressed because one or more lines are too long
4
dist/reveal.min.js
vendored
4
dist/reveal.min.js
vendored
File diff suppressed because one or more lines are too long
135
gulpfile.js
135
gulpfile.js
|
@ -3,8 +3,12 @@ const path = require('path')
|
||||||
const glob = require('glob')
|
const glob = require('glob')
|
||||||
const yargs = require('yargs')
|
const yargs = require('yargs')
|
||||||
const colors = require('colors')
|
const colors = require('colors')
|
||||||
const webpack = require('webpack-stream')
|
const qunit = require('node-qunit-puppeteer')
|
||||||
const { runQunitPuppeteer, printResultSummary, printFailedTests } = require('node-qunit-puppeteer')
|
|
||||||
|
const {rollup} = require('rollup');
|
||||||
|
const {terser} = require('rollup-plugin-terser');
|
||||||
|
const babel = require('rollup-plugin-babel');
|
||||||
|
const resolve = require('@rollup/plugin-node-resolve');
|
||||||
|
|
||||||
const gulp = require('gulp')
|
const gulp = require('gulp')
|
||||||
const tap = require('gulp-tap')
|
const tap = require('gulp-tap')
|
||||||
|
@ -12,8 +16,6 @@ const zip = require('gulp-zip')
|
||||||
const sass = require('gulp-sass')
|
const sass = require('gulp-sass')
|
||||||
const header = require('gulp-header')
|
const header = require('gulp-header')
|
||||||
const eslint = require('gulp-eslint')
|
const eslint = require('gulp-eslint')
|
||||||
const uglify = require('gulp-uglify')
|
|
||||||
const rename = require('gulp-rename')
|
|
||||||
const minify = require('gulp-clean-css')
|
const minify = require('gulp-clean-css')
|
||||||
const connect = require('gulp-connect')
|
const connect = require('gulp-connect')
|
||||||
const autoprefixer = require('gulp-autoprefixer')
|
const autoprefixer = require('gulp-autoprefixer')
|
||||||
|
@ -21,65 +23,83 @@ const autoprefixer = require('gulp-autoprefixer')
|
||||||
const root = yargs.argv.root || '.'
|
const root = yargs.argv.root || '.'
|
||||||
const port = yargs.argv.port || 8000
|
const port = yargs.argv.port || 8000
|
||||||
|
|
||||||
const license = `/*!
|
const banner = `/*!
|
||||||
* reveal.js <%= pkg.version %> (<%= new Date().toDateString() %>)
|
* reveal.js ${pkg.version} (${new Date().toDateString()})
|
||||||
* <%= pkg.homepage %>
|
* ${pkg.homepage}
|
||||||
* MIT licensed
|
* MIT licensed
|
||||||
*
|
*
|
||||||
* Copyright (C) 2020 Hakim El Hattab, https://hakim.se
|
* Copyright (C) 2020 Hakim El Hattab, https://hakim.se
|
||||||
*/\n`
|
*/\n`
|
||||||
|
|
||||||
|
const rollupConfig = {
|
||||||
|
plugins: [
|
||||||
|
babel({
|
||||||
|
exclude: 'node_modules/**',
|
||||||
|
compact: false,
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
corejs: 3,
|
||||||
|
useBuiltIns: 'entry',
|
||||||
|
modules: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
resolve(),
|
||||||
|
terser()
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
const swallowError = function(error) {
|
gulp.task('js', () => {
|
||||||
console.log(error.toString())
|
return rollup({
|
||||||
this.emit('end')
|
input: 'js/index.js',
|
||||||
}
|
...rollupConfig
|
||||||
|
}).then( bundle => {
|
||||||
|
bundle.write({
|
||||||
|
file: './dist/reveal.min.js',
|
||||||
|
format: 'umd',
|
||||||
|
banner: banner
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
gulp.task('js', () => gulp.src(['./js/index.js'])
|
gulp.task('plugins', () => {
|
||||||
.pipe(webpack(require('./webpack.config.js')))
|
return Promise.all([
|
||||||
.on('error', swallowError)
|
{ input: './plugin/highlight/highlight.es5', output: './dist/plugin/highlight.js' },
|
||||||
.pipe(header(license, {pkg: pkg}))
|
{ input: './plugin/markdown/markdown.es5', output: './dist/plugin/markdown.js' },
|
||||||
.pipe(rename('reveal.min.js'))
|
{ input: './plugin/search/search.es5', output: './dist/plugin/search.js' },
|
||||||
.pipe(gulp.dest('./dist')))
|
{ input: './plugin/notes/notes.es5', output: './dist/plugin/notes.js' },
|
||||||
|
{ input: './plugin/zoom/zoom.es5', output: './dist/plugin/zoom.js' },
|
||||||
gulp.task('plugins', () => gulp.src(['./js/index.js'])
|
{ input: './plugin/math/math.es5', output: './dist/plugin/math.js' }
|
||||||
.pipe(webpack({
|
].map( plugin => {
|
||||||
...require('./webpack.config.js'),
|
return rollup({
|
||||||
entry: {
|
input: plugin.input,
|
||||||
'highlight': './plugin/highlight/highlight.es5',
|
...rollupConfig
|
||||||
'markdown': './plugin/markdown/markdown.es5',
|
}).then( bundle => {
|
||||||
'search': './plugin/search/search.es5',
|
return bundle.write({
|
||||||
'notes': './plugin/notes/notes.es5',
|
file: plugin.output,
|
||||||
'zoom': './plugin/zoom/zoom.es5',
|
format: 'umd'
|
||||||
'math': './plugin/math/math.es5'
|
})
|
||||||
},
|
});
|
||||||
output: {
|
} ));
|
||||||
filename: '[name].js'
|
})
|
||||||
}
|
|
||||||
}))
|
|
||||||
.on('error', swallowError)
|
|
||||||
.pipe(gulp.dest('./dist/plugin')))
|
|
||||||
|
|
||||||
gulp.task('css-themes', () => gulp.src(['./css/theme/source/*.{sass,scss}'])
|
gulp.task('css-themes', () => gulp.src(['./css/theme/source/*.{sass,scss}'])
|
||||||
.pipe(sass())
|
.pipe(sass())
|
||||||
.pipe(gulp.dest('./dist/theme')))
|
.pipe(gulp.dest('./dist/theme')))
|
||||||
|
|
||||||
gulp.task('css-core', gulp.series(
|
gulp.task('css-core', () => gulp.src(['css/reveal.scss'])
|
||||||
|
.pipe(sass())
|
||||||
() => gulp.src(['css/reveal.scss'])
|
.pipe(autoprefixer())
|
||||||
.pipe(sass())
|
.pipe(minify({compatibility: 'ie9'}))
|
||||||
.pipe(autoprefixer())
|
.pipe(header(banner))
|
||||||
.pipe(gulp.dest('./dist')),
|
.pipe(gulp.dest('./dist')))
|
||||||
() => gulp.src(['dist/reveal.css'])
|
|
||||||
.pipe(minify({compatibility: 'ie9'}))
|
|
||||||
.pipe(header(license, {pkg: pkg}))
|
|
||||||
.pipe(gulp.dest('./dist'))
|
|
||||||
|
|
||||||
))
|
|
||||||
|
|
||||||
gulp.task('css', gulp.parallel('css-themes', 'css-core'))
|
gulp.task('css', gulp.parallel('css-themes', 'css-core'))
|
||||||
|
|
||||||
gulp.task('test-qunit', function() {
|
gulp.task('qunit', () => {
|
||||||
|
|
||||||
let serverConfig = {
|
let serverConfig = {
|
||||||
root,
|
root,
|
||||||
|
@ -97,7 +117,7 @@ gulp.task('test-qunit', function() {
|
||||||
|
|
||||||
let tests = Promise.all( testFiles.map( filename => {
|
let tests = Promise.all( testFiles.map( filename => {
|
||||||
return new Promise( ( resolve, reject ) => {
|
return new Promise( ( resolve, reject ) => {
|
||||||
runQunitPuppeteer({
|
qunit.runQunitPuppeteer({
|
||||||
targetUrl: `http://${serverConfig.host}:${serverConfig.port}/${filename}`,
|
targetUrl: `http://${serverConfig.host}:${serverConfig.port}/${filename}`,
|
||||||
timeout: 20000,
|
timeout: 20000,
|
||||||
redirectConsole: false,
|
redirectConsole: false,
|
||||||
|
@ -106,8 +126,8 @@ gulp.task('test-qunit', function() {
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if( result.stats.failed > 0 ) {
|
if( result.stats.failed > 0 ) {
|
||||||
console.log(`${'!'} ${filename} [${result.stats.passed}/${result.stats.total}] in ${result.stats.runtime}ms`.red);
|
console.log(`${'!'} ${filename} [${result.stats.passed}/${result.stats.total}] in ${result.stats.runtime}ms`.red);
|
||||||
// printResultSummary(result, console);
|
// qunit.printResultSummary(result, console);
|
||||||
printFailedTests(result, console);
|
qunit.printFailedTests(result, console);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log(`${'✔'} ${filename} [${result.stats.passed}/${result.stats.total}] in ${result.stats.runtime}ms`.green);
|
console.log(`${'✔'} ${filename} [${result.stats.passed}/${result.stats.total}] in ${result.stats.runtime}ms`.green);
|
||||||
|
@ -146,14 +166,13 @@ gulp.task('test-qunit', function() {
|
||||||
} );
|
} );
|
||||||
} )
|
} )
|
||||||
|
|
||||||
gulp.task('test', gulp.series(
|
gulp.task('eslint', () => gulp.src(['./js/**', 'gulpfile.js'])
|
||||||
|
.pipe(eslint())
|
||||||
|
.pipe(eslint.format()))
|
||||||
|
|
||||||
() => gulp.src(['./js/**', 'gulpfile.js']).pipe(eslint()).pipe(eslint.format()),
|
gulp.task('test', gulp.series( 'eslint', 'qunit' ))
|
||||||
'test-qunit'
|
|
||||||
|
|
||||||
))
|
gulp.task('default', gulp.series(gulp.parallel('js', 'css', 'plugins'), 'test'))
|
||||||
|
|
||||||
gulp.task('default', gulp.series(gulp.parallel('js', 'css'), 'test'))
|
|
||||||
|
|
||||||
gulp.task('build', gulp.parallel('js', 'css'))
|
gulp.task('build', gulp.parallel('js', 'css'))
|
||||||
|
|
||||||
|
@ -181,6 +200,8 @@ gulp.task('serve', () => {
|
||||||
|
|
||||||
gulp.watch(['js/**'], gulp.series('js', 'test'))
|
gulp.watch(['js/**'], gulp.series('js', 'test'))
|
||||||
|
|
||||||
|
gulp.watch(['plugin/**/*.js'], gulp.series('plugins'))
|
||||||
|
|
||||||
gulp.watch(['test/*.html'], gulp.series('test'))
|
gulp.watch(['test/*.html'], gulp.series('test'))
|
||||||
|
|
||||||
gulp.watch([
|
gulp.watch([
|
||||||
|
|
1702
package-lock.json
generated
1702
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
|
@ -26,30 +26,29 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.8.7",
|
"@babel/core": "^7.8.7",
|
||||||
"@babel/preset-env": "^7.8.7",
|
"@babel/preset-env": "^7.8.7",
|
||||||
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
||||||
"babel-eslint": "^10.1.0",
|
"babel-eslint": "^10.1.0",
|
||||||
"babel-loader": "^8.1.0",
|
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-autoprefixer": "^7.0.1",
|
"gulp-autoprefixer": "^7.0.1",
|
||||||
"gulp-babel": "^8.0.0",
|
|
||||||
"gulp-clean-css": "^4.2.0",
|
"gulp-clean-css": "^4.2.0",
|
||||||
"gulp-connect": "^5.7.0",
|
"gulp-connect": "^5.7.0",
|
||||||
"gulp-eslint": "^6.0.0",
|
"gulp-eslint": "^6.0.0",
|
||||||
"gulp-header": "^2.0.9",
|
"gulp-header": "^2.0.9",
|
||||||
"gulp-rename": "^2.0.0",
|
|
||||||
"gulp-sass": "^4.0.2",
|
"gulp-sass": "^4.0.2",
|
||||||
"gulp-tap": "^2.0.0",
|
"gulp-tap": "^2.0.0",
|
||||||
"gulp-uglify": "^3.0.2",
|
|
||||||
"gulp-zip": "^5.0.1",
|
"gulp-zip": "^5.0.1",
|
||||||
"mustache": "^4.0.0",
|
"mustache": "^4.0.0",
|
||||||
"node-qunit-puppeteer": "^2.0.1",
|
"node-qunit-puppeteer": "^2.0.1",
|
||||||
|
"rollup": "^2.6.1",
|
||||||
|
"rollup-plugin-babel": "^4.4.0",
|
||||||
|
"rollup-plugin-terser": "^5.3.0",
|
||||||
"socket.io": "^2.3.0",
|
"socket.io": "^2.3.0",
|
||||||
"webpack-stream": "^5.2.1",
|
|
||||||
"yargs": "^15.1.0"
|
"yargs": "^15.1.0"
|
||||||
},
|
},
|
||||||
"browserslist": "last 2 versions, > 0.5%, not dead",
|
"browserslist": "> 0.5%, IE 11, not dead",
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
|
@ -89,6 +88,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"highlight.js": "^9.18.1"
|
"core-js": "^3.6.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
mode: 'production',
|
|
||||||
entry: ['./js/index.js'],
|
|
||||||
output: {
|
|
||||||
path: path.join(__dirname, '/dist'),
|
|
||||||
filename: 'reveal.min.js',
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.js$/,
|
|
||||||
exclude: /(node_modules)/,
|
|
||||||
loader: 'babel-loader',
|
|
||||||
query: {
|
|
||||||
presets: [
|
|
||||||
[ '@babel/preset-env' ]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
Loading…
Reference in New Issue
Block a user