0
votes

I have a gulp file that looks like this,

    const paths = {
  styles: {
    src: 'src/styles/**/*.scss',
    dest: 'dist/styles',
  },
  javascript: {
    src: 'src/scripts/**/*.js',
    dest: 'dist/scripts',
  },
  copy: {
    pluginsFile: 'src/scripts/plugins.js',
    pluginsFolder: 'src/scripts/plugins/**',
    mapsFolder: 'src/scripts/maps/**',
  },
  files: './**/*.php',
};

    function javascript() {
  gulp
    .src(paths.copy.pluginsFolder)
    .pipe(gulp.dest(`${paths.javascript.dest}/plugins`));

  gulp.src(paths.copy.pluginsFile).pipe(gulp.dest(paths.javascript.dest));

  gulp
    .src(paths.copy.mapsFolder)
    .pipe(gulp.dest(`${paths.javascript.dest}/maps`));

  const jsFiles = glob.sync(paths.javascript.src);

  return browserify({
    entries: jsFiles,
    transform: [babelify.configure({ presets: ['@babel/preset-env'] })],
  })
    .bundle()
    .pipe(source('bundle.js'))
    .pipe(buffer())
    .pipe(uglify())
    .pipe(gulp.dest(paths.javascript.dest))
    .pipe(browserSync.stream());
}

I have a file in in 'src/scripts/visualiser.js' that I want to exclude from going into my bundle how would I go about that?

I have since changed my paths object to be the following,

const paths = {
  styles: {
    src: 'src/styles/**/*.scss',
    dest: 'dist/styles',
  },
  javascript: {
    src: ['src/scripts/**/*.js', '!src/scripts/three-d-scripts.js'],
    dest: 'dist/scripts',
  },
  copy: {
    pluginsFile: 'src/scripts/plugins.js',
    pluginsFolder: 'src/scripts/plugins/**',
    mapsFolder: 'src/scripts/maps/**',
  },
  files: './**/*.php',
};

I know get the following gulp errors,

TypeError: glob pattern string required

This is from this line, const jsFiles = glob.sync(paths.javascript.src);

changing this line to,

const jsFiles = paths.javascript.src;

returns the following error,

Can't walk dependency graph: Cannot find module '/Users/simon/Sites/website/website/wp-content/themes/storefront-child-website/!src/scripts/three-d-scripts.js' from '/Users/simon/Sites/website/website/wp-content/themes/storefront-child-website/!src/scripts/_fake.js'

Does this answer your question? Excluding files/directories from Gulp taskKrullmizter
@Krullmizter Please see question edit.Udders
Is jsFiles an array? Can you just .filter to remove the one you want to not include?crashmstr
could you try to write the path like this one? !./src/scripts/three-d-scripts.jsJoseph