Code Monkey home page Code Monkey logo

gulp-extensions's Introduction

Lombiq Gulp Extensions

Deprecation notice

This project is being deprecated, and support for it will be ceased. Please consider migrating to our Node.js Extensions project, which provides pre-configured frontend asset pipelines out of the box, without using Gulp.

About

Various JavaScript functions and Gulp tasks that can be handy when developing Gulp pipelines.

When adding this project to the solution it will initialize a node_modules folder two levels up in the folder hierarchy assuming that it will be a common root folder for all the other package.json files. This way it makes it possible to keep the package.json files light (e.g. adding the gulp Node module won't be necessary) by using a single, common node_modules folder (see the Node docs).

Also see our NPM MSBuild Targets library that can make NPM package management a lot easier.

We at Lombiq also used this utility for the new client portal for WTW (see case study).

Do you want to quickly try out this project and see it in action? Check it out in our Open-Source Orchard Core Extensions full Orchard Core solution and also see our other useful Orchard Core-related open-source projects!

Installation and usage

It's recommended that you put this project into a folder named Lombiq.Gulp.Extensions and under the src/Utilities folder.

Integrating with MSBuild

If you want to integrate ESLint and Stylelint into MSBuild builds then you need to include Lombiq's NPM MSBuild Targets too. Make sure you have a package.json file with the dotnet-prebuild and dotnet-clean scripts as indicated in the repository's readme. In the affected projects, you need to import these files in the .csproj file:

<Import Project="path\to\Lombiq.Npm.Targets\Lombiq.Npm.Targets.props" />
<Import Project="path\to\Lombiq.Npm.Targets\Lombiq.Npm.Targets.targets" />
<Import Project="path\to\Lombiq.Gulp.Extensions\Lombiq.Gulp.Extensions.targets"/>

Then, warnings will be sent to the error list if the linters find rule violations.

Note that when building a solution that utilizes this project from the command line (i.e. with the dotnet build or msbuild commands) you have to build this project alone first. Otherwise, you'll get "Local gulp not found" errors. Building from Visual Studio doesn't need any special care.

Gulp tasks

Included Gulp tasks

Tips for using and naming multiple Gulp tasks

It's recommended to have conventionally named tasks for stylesheets and scripts. We use the build:styles/build:scripts convention, and similar pairs for clean (you may also do this for watch). To allow convenient development, we recommend that you add build, clean, and watch tasks as well. We've included a module to set up all the recommended targets automatically:

const recommendedSetup = require('../../Utilities/Lombiq.Gulp.Extensions/recommended-setup');

recommendedSetup.setupRecommendedScssAndJsTasks();

// Or either of these:
recommendedSetup.setupRecommendedJsTasks();
recommendedSetup.setupRecommendedScssTasks();

// And if you want to change e.g. the output path:
recommendedSetup.setupRecommendedScssAndJsTasks('./StylesGoHere/');

// There's also recommendedSetup.setupCopyAssets(assets) and several other such shortcuts.

Or here's an sample of a Gulpfile that demonstrates the whole approach:

const gulp = require('gulp');
const watch = require('gulp-watch');
const babel = require('gulp-babel');
const scssTargets = require('../../Utilities/Lombiq.Gulp.Extensions/Tasks/scss-targets');
const jsTargets = require('../../Utilities/Lombiq.Gulp.Extensions/Tasks/js-targets');

const assetsBasePath = './Assets/';
const distBasePath = './wwwroot/';
const stylesBasePath = assetsBasePath + 'Styles/';
const stylesDistBasePath = distBasePath + 'css/';
const scriptsBasePath = assetsBasePath + 'Scripts/';
const scriptsDistBasePath = distBasePath + 'js/';

gulp.task('build:styles', scssTargets.build(stylesBasePath, stylesDistBasePath));
gulp.task('clean:styles', scssTargets.clean(stylesDistBasePath));

gulp.task(
    'build:scripts',
    () => jsTargets.compile(
        scriptsBasePath, scriptsDistBasePath, (pipeline) => pipeline.pipe(babel({ presets: ['@babel/preset-env'] }))));

gulp.task('clean:scripts', jsTargets.clean(scriptsDistBasePath));

gulp.task('clean', gulp.parallel('clean:styles', 'clean:scripts'));

gulp.task('default', gulp.parallel('build:styles', 'build:scripts'));

gulp.task('watch', () => {
    watch(stylesBasePath + '**/*.scss', { verbose: true }, gulp.series('build:styles'));
    watch(scriptsBasePath + '**/*.js', { verbose: true }, gulp.series('build:scripts'));
});

Using PNPM for package restore

See our notes on PNPM here.

Contributing and support

If ESLint's or any ESLint plugin's version is updated in Gulp Extension's package.json, please update vs-eslint-package.json too.

Bug reports, feature requests, comments, questions, code contributions and love letters are warmly welcome. You can send them to us via GitHub issues and pull requests. Please adhere to our open-source guidelines while doing so.

This project is developed by Lombiq Technologies. Commercial-grade support is available through Lombiq.

gulp-extensions's People

Contributors

0liver avatar barthamark avatar benedekfarkas avatar demeszabolcs avatar dministro avatar domonkosgabor avatar i3undy avatar luko6 avatar mzole avatar piedone avatar porgabi avatar sarahelsaig avatar wasnk avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gulp-extensions's Issues

[email protected] is not compatible with current Node LTS

When using the LTS version of node, which is currently is v16, the accompanying npm version throws the following error

It looks like gulp-stylelint is no longer being maintained so a new version might need to be found. using Node 14.20.0 fixes the issue.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/stylelint
npm ERR!   dev stylelint@"^14.0.1" from the root project
npm ERR!   peer stylelint@"^14.0.0" from [email protected]
npm ERR!   node_modules/stylelint-config-recommended
npm ERR!     stylelint-config-recommended@"^6.0.0" from [email protected]
npm ERR!     node_modules/stylelint-config-recommended-scss
npm ERR!       stylelint-config-recommended-scss@"^5.0.0" from [email protected]
npm ERR!       node_modules/stylelint-config-standard-scss
npm ERR!         dev stylelint-config-standard-scss@"^2.0.0" from the root project
npm ERR!     stylelint-config-recommended@"^6.0.0" from [email protected]
npm ERR!     node_modules/stylelint-config-standard
npm ERR!       stylelint-config-standard@"^23.0.0" from [email protected]
npm ERR!       node_modules/stylelint-config-standard-scss
npm ERR!         dev stylelint-config-standard-scss@"^2.0.0" from the root project
npm ERR!   4 more (stylelint-config-recommended-scss, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer stylelint@"^13.0.0" from [email protected]
npm ERR! node_modules/gulp-stylelint
npm ERR!   dev gulp-stylelint@"^13.0.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/stylelint
npm ERR!   peer stylelint@"^13.0.0" from [email protected]
npm ERR!   node_modules/gulp-stylelint
npm ERR!     dev gulp-stylelint@"^13.0.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 

Linting Gulpfile.js

Having ESLint in place, wouldn't it be consequent to run it on the Gulpfile itself, too?

This would help keep the Gulpfile clean and adhere to the same (strict) rules we use everywhere else.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.