5

A)
const gulp = require("gulp"),
sass = require("gulp-sass");
OR

B)
const gulp = require("gulp"),
const sass = require("gulp-sass");

I use A

Comments
  • 4
    import gulp from 'gulp'
  • 1
    @lucaspar that's new to me but would you reuse the word import like

    import gulp from 'gulp',

    import sass from 'gulp-sass' ?
  • 1
  • 0
  • 0
    @norman70688 what difference does it makes?
  • 1
    @norman70688 what's the difference between A and C
  • 2
    Webpack ;)
  • 0
  • 0
    @nothappy what do you mean?
  • 0
    @lucaspar I want to know the difference we use A and C, like why C over A or B? Or if A or B, why?

    I use A because I hate to re declare variable
  • 0
    C is more readable
  • 0
    @nothappy you're not redeclaring anything, gulp and sass are two different constants
  • 0
    Laravel mix (even for not laravel projects)
  • 1
    I might be the only one who does this but I put all my initializers in top, grouped up.

    e.g. if I wanted to import mongoose to connect to a mongo instance, and then import a scheme and make a model out of it, and then initialize an Express web server

    /* DB */
    const mongoose = require("mongoose")
    mongoose.connect(/* do de connects */)

    const schema = require("./schema.js")
    const User = mongoose.model('User', schema.user)

    /* Server */
    const express = require("express")
    const app = express()
    app.use(express.json())
    app.use(express.static('./static'))

    /* *********** */

    I find it somewhat more organized and it makes it easier to edit initializations and work with long scripts that have lots of pieces that are too small to be their own file but too big to be intermittently stitched while maintaining readability.

    Of course I also rely on my format code shortcut to put in semicolons and properly format things so maybe I'm just a heathen through and through 😅
Add Comment