webpack config + babel-loader

edit
Hakim El Hattab 2020-03-31 13:23:51 +02:00
parent e4faf54804
commit ca29e3dd29
5 changed files with 76 additions and 8 deletions

2
dist/reveal.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
const pkg = require('./package.json') const pkg = require('./package.json')
const path = require('path') const path = require('path')
const glob = require('glob') const glob = require('glob')
const colors = require('colors')
const yargs = require('yargs') const yargs = require('yargs')
const colors = require('colors')
const webpack = require('webpack-stream') const webpack = require('webpack-stream')
const { runQunitPuppeteer, printResultSummary, printFailedTests } = require('node-qunit-puppeteer') const { runQunitPuppeteer, printResultSummary, printFailedTests } = require('node-qunit-puppeteer')
@ -10,7 +10,6 @@ const gulp = require('gulp')
const tap = require('gulp-tap') const tap = require('gulp-tap')
const zip = require('gulp-zip') const zip = require('gulp-zip')
const sass = require('gulp-sass') const sass = require('gulp-sass')
const babel = require('gulp-babel')
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 uglify = require('gulp-uglify')
@ -37,8 +36,7 @@ const swallowError = function(error) {
} }
gulp.task('js', () => gulp.src(['./js/index.js']) gulp.task('js', () => gulp.src(['./js/index.js'])
.pipe(babel({ presets: ['@babel/preset-env'] })) .pipe(webpack(require('./webpack.config.js')))
.pipe(webpack({ mode: 'production' }))
.on('error', swallowError) .on('error', swallowError)
.pipe(header(license, {pkg: pkg})) .pipe(header(license, {pkg: pkg}))
.pipe(rename('reveal.min.js')) .pipe(rename('reveal.min.js'))
@ -55,9 +53,7 @@ gulp.task('css-core', gulp.series(
.pipe(autoprefixer()) .pipe(autoprefixer())
.pipe(gulp.dest('./dist')), .pipe(gulp.dest('./dist')),
() => gulp.src(['dist/reveal.css']) () => gulp.src(['dist/reveal.css'])
.pipe(minify({ .pipe(minify({compatibility: 'ie9'}))
compatibility: 'ie9'
}))
.pipe(header(license, {pkg: pkg})) .pipe(header(license, {pkg: pkg}))
.pipe(gulp.dest('./dist')) .pipe(gulp.dest('./dist'))

46
package-lock.json generated
View File

@ -1651,6 +1651,52 @@
"resolve": "^1.12.0" "resolve": "^1.12.0"
} }
}, },
"babel-loader": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.1.0.tgz",
"integrity": "sha512-7q7nC1tYOrqvUrN3LQK4GwSk/TQorZSOlO9C+RZDZpODgyN4ZlCqE5q9cDsyWOliN+aU9B4JX01xK9eJXowJLw==",
"dev": true,
"requires": {
"find-cache-dir": "^2.1.0",
"loader-utils": "^1.4.0",
"mkdirp": "^0.5.3",
"pify": "^4.0.1",
"schema-utils": "^2.6.5"
},
"dependencies": {
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true
},
"mkdirp": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.4.tgz",
"integrity": "sha512-iG9AK/dJLtJ0XNgTuDbSyNS3zECqDlAhnQW4CsNxBG3LQJBbHmRX1egw39DmtOdCAqY+dKXV+sgPgilNWUKMVw==",
"dev": true,
"requires": {
"minimist": "^1.2.5"
}
},
"pify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==",
"dev": true
},
"schema-utils": {
"version": "2.6.5",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.6.5.tgz",
"integrity": "sha512-5KXuwKziQrTVHh8j/Uxz+QUbxkaLW9X/86NBlx/gnKgtsZA2GIVMUn17qWhRFwF8jdYb3Dig5hRO/W5mZqy6SQ==",
"dev": true,
"requires": {
"ajv": "^6.12.0",
"ajv-keywords": "^3.4.1"
}
}
}
},
"babel-plugin-dynamic-import-node": { "babel-plugin-dynamic-import-node": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz", "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz",

View File

@ -27,6 +27,7 @@
"@babel/core": "^7.8.7", "@babel/core": "^7.8.7",
"@babel/preset-env": "^7.8.7", "@babel/preset-env": "^7.8.7",
"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",
@ -48,6 +49,7 @@
"webpack-stream": "^5.2.1", "webpack-stream": "^5.2.1",
"yargs": "^15.1.0" "yargs": "^15.1.0"
}, },
"browserslist": "last 2 versions, > 0.5%, not dead",
"eslintConfig": { "eslintConfig": {
"env": { "env": {
"browser": true, "browser": true,

24
webpack.config.js 100644
View File

@ -0,0 +1,24 @@
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' ],
],
},
},
],
},
};