Skip to content

Commit

Permalink
Добавлена bundler esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
niknov80 committed Apr 8, 2023
1 parent f30f052 commit ba61ad8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
24 changes: 8 additions & 16 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cheerio from 'gulp-cheerio';
import csso from 'postcss-csso';
import data from 'gulp-data';
import { deleteSync } from 'del';
import esbuild from 'gulp-esbuild';
import fs from 'fs';
import notify from 'gulp-notify';
import plumber from 'gulp-plumber';
Expand All @@ -13,10 +14,8 @@ import rename from 'gulp-rename';
import render from 'gulp-nunjucks-render';
import sass from 'gulp-dart-sass';
import sharpOptimizeImages from 'gulp-sharp-optimize-images';
import sourcemaps from 'gulp-sourcemaps';
import svgmin from 'gulp-svgmin';
import svgstore from 'gulp-svgstore';
import webpack from 'webpack-stream';
const { src, dest, watch, parallel, series } = gulp;

/**
Expand Down Expand Up @@ -45,7 +44,7 @@ const path = {
json: `${dirs.src}/data.json`,
scripts: {
root: `${dirs.src}/static/js/`,
compile: `${dirs.src}/static/js/main.js`,
compile: `${dirs.src}/static/js/script.js`,
save: `${dirs.dest}/static/js/`
},
fonts: {
Expand Down Expand Up @@ -82,11 +81,6 @@ const imageOptimizeConfigs = {
}
}

const mode = {
isBuild: process.argv.includes('--build'),
isDev: !process.argv.includes('--build')
}

/**
* Основные задачи
*/
Expand Down Expand Up @@ -123,19 +117,17 @@ export const templates = () => src(`${path.templates.pages}*.j2`)
}))
.pipe(dest(path.templates.save));

export const scripts = () => src(`${path.scripts.root}**/*.js`)
export const scripts = () => src(path.scripts.compile)
.pipe(plumber(notify.onError({
title: 'SCRIPTS',
message: 'Error: <%= error.message %>'
})))
.pipe(sourcemaps.init())
.pipe(webpack({
mode: mode.isBuild ? 'production' : 'development',
output: {
filename: 'script.min.js',
}
.pipe(esbuild({
outfile: 'script.min.js',
bundle: true,
minify: true,
sourcemap: 'both'
}))
.pipe(sourcemaps.write('./'))
.pipe(dest(path.scripts.save));

export const clean = (done) => {
Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
"gulp-csscomb": "latest",
"gulp-dart-sass": "latest",
"gulp-data": "latest",
"gulp-if": "^3.0.0",
"gulp-esbuild": "latest",
"gulp-merge-json": "latest",
"gulp-notify": "latest",
"gulp-nunjucks-render": "latest",
"gulp-plumber": "latest",
"gulp-postcss": "latest",
"gulp-rename": "latest",
"gulp-sharp-optimize-images": "latest",
"gulp-sourcemaps": "latest",
"gulp-svgmin": "latest",
"gulp-svgstore": "latest",
"pixel-glass": "github:makehtml/pixel-glass",
Expand All @@ -30,16 +29,14 @@
"stylelint": "latest",
"stylelint-config-recess-order": "latest",
"stylelint-config-standard": "latest",
"stylelint-scss": "latest",
"webpack": "latest",
"webpack-stream": "latest"
"stylelint-scss": "latest"
},
"browserslist": [
"last 2 version",
"> 2%"
],
"scripts": {
"build": "gulp build --build",
"build": "gulp build",
"start": "gulp start",
"lint:styles": "stylelint 'src/sass/**/*.scss' --config .stylelintrc.json",
"lint:templates": "djlint src/templates --lint --configuration .djlintrc",
Expand Down

0 comments on commit ba61ad8

Please sign in to comment.