Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gulp esm #2831

Merged
merged 5 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module.exports = {
plugins: ['mocha'],
extends: 'eslint:recommended',
parserOptions: {
sourceType: 'module'
'ecmaVersion': 2020,
'sourceType': 'module'
},
rules: {
indent: ['error', 2],
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ way that you want.
This repository is where HTML5-Boilerplate is authored. Some of the tools,
files and processes that you see here are solely for the _production_ of
HTML5 Boilerplate and are not _part_ of HTML5 Boilerplate. For one example, the
[gulpfile.babel.js](https://github.com/h5bp/html5-boilerplate/blob/main/gulpfile.babel.js)
[gulpfile.mjs](https://github.com/h5bp/html5-boilerplate/blob/main/gulpfile.mjs)
script is used to _build_ the project. It's not part of the project itself.

The project we publish is represented by the contents of the `/dist/`
Expand Down
4 changes: 2 additions & 2 deletions dist/js/vendor/modernizr-3.12.0.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start": "webpack-dev-server --open --port 8080"
},
"devDependencies": {
"webpack": "^5.73.0",
"webpack": "^5.74.0",
"html-webpack-plugin": "^5.5.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.9.3"
Expand Down
53 changes: 26 additions & 27 deletions gulpfile.babel.js → gulpfile.mjs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import fs from 'fs';
import path from 'path';

import gulp from 'gulp';

// Load all gulp plugins automatically
// and attach them to the `plugins` object
import plugins from 'gulp-load-plugins';

import gulpAutoPrefixer from 'gulp-autoprefixer';
import gulpEslint from 'gulp-eslint';
import gulpHeader from 'gulp-header';
import gulpRename from 'gulp-rename';
import gulpReplace from 'gulp-replace';
import archiver from 'archiver';
import glob from 'glob';
import del from 'del';
import { deleteSync } from 'del';
import modernizr from 'modernizr';

import pkg from './package.json';
import modernizrConfig from './modernizr-config.json';
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const pkg = require('./package.json');
const modernizrConfig = require('./modernizr-config.json');

const dirs = pkg['h5bp-configs'].directories;

Expand Down Expand Up @@ -65,20 +65,19 @@ gulp.task('archive:zip', (done) => {
});

gulp.task('clean', (done) => {
del([
deleteSync([
dirs.archive,
dirs.dist
]).then(() => {
done();
});
]);
done();
});

gulp.task('copy:index.html', () => {

let modernizrVersion = pkg.devDependencies.modernizr;

return gulp.src(`${dirs.src}/index.html`)
.pipe(plugins().replace(/{{MODERNIZR_VERSION}}/g, modernizrVersion))
.pipe(gulpReplace(/{{MODERNIZR_VERSION}}/g, modernizrVersion))
.pipe(gulp.dest(dirs.dist));
});

Expand All @@ -91,11 +90,11 @@ gulp.task('copy:style', () => {
const banner = `/*! HTML5 Boilerplate v${pkg.version} | ${pkg.license} License | ${pkg.homepage} */\n\n`;

return gulp.src('node_modules/main.css/dist/main.css')
.pipe(plugins().header(banner))
.pipe(plugins().autoprefixer({
.pipe(gulpHeader(banner))
.pipe(gulpAutoPrefixer({
cascade: false
}))
.pipe(plugins().rename({
.pipe(gulpRename({
basename: 'style'
}))
.pipe(gulp.dest(`${dirs.dist}/css`));
Expand Down Expand Up @@ -135,22 +134,22 @@ gulp.task('modernizr', (done) => {
gulp.task('lint:js', () =>
gulp.src([
`${dirs.src}/js/*.js`,
`${dirs.test}/*.js`
]).pipe(plugins().eslint())
.pipe(plugins().eslint.failOnError())
`${dirs.test}/*.mjs`
]).pipe(gulpEslint())
.pipe(gulpEslint.failOnError())
);

// ---------------------------------------------------------------------
// | Main tasks |
// ---------------------------------------------------------------------
gulp.task(
"copy",
'copy',
gulp.series(
"copy:index.html",
"copy:license",
"copy:style",
"copy:misc",
"copy:normalize"
'copy:index.html',
'copy:license',
'copy:style',
'copy:misc',
'copy:normalize'
)
);

Expand Down