vigetlabs / blendid

A delicious blend of gulp tasks combined into a configurable asset pipeline and static site builder
MIT License
4.97k stars 682 forks source link

Add static files from node modules #482

Open york-xtrem opened 7 years ago

york-xtrem commented 7 years ago

I don't know if it's a feature request or a how to do. I'm looking if there is any way to add files from node modules including the path in some way.

I've tried this:

// config/path-config.json

{
  "static": {
    "src": ["static", "node_modules/apache-server-configs/dist/.htaccess"],
    "dest": "./"
  }
}

But I see that it makes a Join and of course it does not work.

//gulpfile.js/tasks/static.js

if(!TASK_CONFIG.static) return

const changed = require('gulp-changed')
const gulp    = require('gulp')
const path    = require('path')

const staticTask = function() {
  const srcPath = path.resolve(process.env.PWD, PATH_CONFIG.src, PATH_CONFIG.static.src)
  const defaultSrcOptions = { dot: true }
  const options = Object.assign(defaultSrcOptions, (TASK_CONFIG.static.srcOptions || {}))

  const paths = {
    src: [
      path.join(srcPath, '**/*'),
      path.resolve(process.env.PWD, '!' + PATH_CONFIG.src, PATH_CONFIG.static.src, 'README.md')
    ],
    dest: path.resolve(process.env.PWD, PATH_CONFIG.dest, PATH_CONFIG.static.dest)
  }

  return gulp.src(paths.src, options)
    .pipe(gulp.dest(paths.dest))
}

gulp.task('static', staticTask)
module.exports = staticTask
benjtinsley commented 6 years ago

@york-xtrem i am a bit confused by the reasoning behind your request. do you just need the contents of the .htaccess defined in node_modules/apache-server-configs/dist/ to be available in your project? if so, why not just copy it with a comment mentioning its source?

york-xtrem commented 6 years ago

@benjtinsley We use Blendid multiple people in our company. I want to automate this process to avoid human errors and that someone does not copy the .htaccess in static. Now I have more knowledge about node and I will try to do a pull request.