Giter Club home page Giter Club logo

webpack-stream's People

Contributors

3onyc avatar abergs avatar ampedandwired avatar btipling avatar chalarangelo avatar chiplay avatar chrisgalliano avatar damassi avatar demurgos avatar dyingsunlight avatar earshinov avatar elierotenberg avatar francescelies avatar jeffling avatar jeroennoten avatar jmurzy avatar koistya avatar kompot avatar lgladdy avatar marekdedic avatar martinduparc avatar mdreizin avatar oliverjash avatar raphaelluchini avatar saschagehlich avatar shama avatar simek avatar sindresorhus avatar sirlancelot avatar thereverand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webpack-stream's Issues

How to run synchronously or chain properly with gulp?

I have this gulp task

gulp.task('react', function() {
    gulp.src('./views/react/**/*.jsx')
        .pipe(named())
        .pipe(webpack(webpack_conf))
        .pipe(concat('react-templates.js'))
        .pipe(gulp.dest('./public/js'));
});

when I run gulp react I get the react task finishing immediatly

kevzettler$ gulp react
[11:59:33] Using gulpfile ~/ct/crowdtilt-public-site/gulpfile.js
[11:59:33] Starting 'react'...
[11:59:33] Finished 'react' after 232 ms
[11:59:40] Version: webpack 1.4.13
                        Asset    Size  Chunks             Chunk Names

you can see the Finished 'react' output comes before the final webpack output. This will cause my subsequent gulp tasks that are dependent on this one to execute prematurely before webpack has finished.

Webpack watch prevents further gulp execution

When running webpack with the watch option set to true, it prevents any further execution of gulp tasks.
Any tricks to fix this? I want to use also my other gulp tasks that run with gulp-watch.

[10:17:54] Starting 'webpack'...
[10:18:06] Version: webpack 1.5.3
        Asset     Size  Chunks             Chunk Names
    vendor.js  1776086       0  [emitted]  vendor
       app.js  1720552       1  [emitted]  app
vendor.js.map  2105617       0  [emitted]  vendor
   app.js.map  2131789       1  [emitted]  app
[10:18:06] Webpack is watching for changes

Ability to disable colors

I am invoking gulp <task> --no-color. All other tasks suppress their colors, but gulp-webpack does not.

Please add the ability to suppress color in the output, ideally automatically upon detecting --no-color.

Pipe output from `gulp-mustache` in as webpack entry point

The code of the Webpack entry point of my JavaScript app varies for different Gulp tasks, so I am putting it through a Mustache template before piping it to Webpack (using gulp-mustache and gulp-webpack):

gulp.task('webpack', function() {
  return gulp.src('./index.js.mustache')
    .pipe(mustache({
      suffix: '.min.js'
    }))
   .pipe(webpack(config))
   .pipe(gulp.dest('dist/js'));
});

Unfortunately this doesn't work as expected. gulp-webpack seems to use the original filename (index.js.mustache) rather than the new contents of the file, so the changes made by the Mustache template are ignored.

In order to get it to work I have to say:

gulp.task('webpack', function() {
  return gulp.src('./index.js.mustache')
    .pipe(mustache({
      suffix: '.min.js'
    }))
   .pipe(rename('index.js'))
   .pipe(gulp.dest('.'))
   .pipe(webpack(config))
   .pipe(gulp.dest('dist/js'));
});

It seems wrong to me that I have to use an intermediate file though. Is there some way to get gulp-webpack to use the stream properly?

Handle sourcemaps

self.queue(new File({
    base: compiler.outputPath,
    path: path,
    contents: contents,
}));

Plugin should also read sourcemap and attach it by using, for example vinyl-sourcemaps-apply package.

--progress support

Whould be nice to see the progress while running the webpack task. This can be done with the ProgressPlugin provided by Webpack.

Example; webpack --progress

How to use loaders with multiple entry points?

The example from the Readme using named for multiple entry points dosen't show how to pass config:

var gulp = require('gulp');
var webpack = require('gulp-webpack');
var named = require('vinyl-named');
gulp.task('default', function() {
  return gulp.src(['src/app.js', 'test/test.js'])
    .pipe(named())
    .pipe(webpack())
    .pipe(gulp.dest('dist/'));
});

I've tried

var webpack_conf = {
    output: {
        path: __dirname + 'public/js',
        filename: 'react-templates.js'
    },
    resolve: {
        extensions: ['', '.js', '.jsx']
    },
    module: {
        loaders: [
            { test: /\.jsx?$/, loader: 'jsx-loader?harmony' }
        ]
    }
};

gulp.task('react', function() {
    gulp.src('./views/react/**/*.jsx')
        .pipe(named())
        .pipe(webpack(webpack_conf))
        .pipe(gulp.dest('./public/js'));
});

but that silently fails possibly because I don't have an entrypoint set in the config?

Problems with multiple entry points and 'named' plugin

Hi! Thanks for the great plugin to begin with!

Defining multiple entry points (https://github.com/shama/gulp-webpack#multiple-entry-points) with named() does not work as I would expect it.

Let's say I have the structure

- a
  - main.js 
- b
  - main.js

and apply

gulp.src('**/main.js')
  .pipe(named())
  .pipe(webpack())
  .pipe(gulp.dest('dist'));

I would aspect in dist to have two compiled bundles as I would get using

entry: {
    'one': 'path/to/one.js',
    'two': 'path/to/two.js',
  }

but I only get one dist/main.js. Am I doing something wrong?

How to only enable error logs?

Hello,

I would like to disable regular logs (see below) to see only error logs.

The quiet option do not display error logs anymore.

Do you have any solutions?

    Asset       Size  Chunks             Chunk Names
  home.js  597 bytes       0  [emitted]  home
  main.js  663 bytes       1  [emitted]  main
common.js     297 kB       2  [emitted]  common

The `recordsOutputPath` webpack option doesn't work

STR:

{
  entry: ...,
  output: {
    filename: '[name].js'
  },
  recordsPath: path.join(__dirname, 'webpack_records.json')
  ...
}
  • Run the gulp-webpack task
  • Expected webpack_records.json file to be present. Actual: file not being generated.

It appears that gulp-webpack configures webpack's outputFileSystem with MemoryFileSystem, which leads to the records output file being lost.

Stream in files to gulp-webpack

I was wondering if its possible to extend things so that one can stream in the files to gulp-webpack. Its just that I do some pre processing of the files outside of webpack and would prefer not to have to send them to disk before running webpack. This might require changes at webpacks end but not being intermit with how gulp works, I'm not sure where the change needs to go.

Cannot keep source file sub-directories

I try to use webpack with vinyl-name to compile my scripts like the demo:

var gulp = require('gulp');
var webpack = require('webpack-stream');
var named = require('vinyl-named');
gulp.task('default', function() {
  return gulp.src(['src/*.js', 'src/**/*.js'])
    .pipe(named())
    .pipe(webpack())
    .pipe(gulp.dest('dist/'));
});

But js files in src/** are compiled to the root directory in dist/ like this:

  • src/base.js --> dist/base.js // This is right
  • src/user/login.js --> dist/login.js // This should be in dist/user/login.js

How can I make it right?

Poor error reporting on non-existent source file

Using the following code...

gulp.task('webpack', function(){
    return gulp.src("lib-client/index.cofee")
        .pipe(webpack({
            watch: true,
            module: {
                loaders: [{ test: /\.coffee$/, loader: "coffee-loader" }]
            },
            resolve: { extensions: ["", ".web.coffee", ".web.js", ".coffee", ".js"] }
        }))
        .pipe(rename("stats.js"))
        .pipe(gulp.dest("static/js/"));
});

... I got the following error:

Error: Path doesn't exist '/home/sven/projects/cdn/412d142f659f7fef34e4.js'
  at MemoryFileSystem.writeFileSync (/home/sven/projects/cdn/node_modules/gulp-webpack/node_modules/memory-fs/lib/MemoryFileSystem.js:176:10)
  at MemoryFileSystem.writeFile (/home/sven/projects/cdn/node_modules/gulp-webpack/node_modules/memory-fs/lib/MemoryFileSystem.js:221:8)
  at Tapable.writeOut (/home/sven/projects/cdn/node_modules/gulp-webpack/node_modules/webpack/lib/Compiler.js:256:27)
  at Tapable.<anonymous> (/home/sven/projects/cdn/node_modules/gulp-webpack/node_modules/webpack/lib/Compiler.js:242:20)
  at /home/sven/projects/cdn/node_modules/gulp-webpack/node_modules/webpack/node_modules/async/lib/async.js:125:13
  at Array.forEach (native)
  at _each (/home/sven/projects/cdn/node_modules/gulp-webpack/node_modules/webpack/node_modules/async/lib/async.js:46:24)
  at Object.async.each (/home/sven/projects/cdn/node_modules/gulp-webpack/node_modules/webpack/node_modules/async/lib/async.js:124:9)
  at Tapable.emitFiles (/home/sven/projects/cdn/node_modules/gulp-webpack/node_modules/webpack/lib/Compiler.js:231:20)
  at /home/sven/projects/cdn/node_modules/gulp-webpack/node_modules/webpack/node_modules/mkdirp/index.js:47:26
  at Object.oncomplete (fs.js:107:15)

After way too much time debugging, I found out that I'd accidentally typed .cofee for my source file instead of .coffee, and this was making the build fail - however, there's no indication of this in the error whatsoever (which instead points at a non-existent file path, presumably in the virtual in-memory filesystem).

There should probably be a clearer error message here, indicating that no valid source file was specified or something along those lines.

muti files for watch with webpack and gulp

I use webpack in website with a lot of js and html files.
I just want use webpack watch files and build differen bundle files ,every file will be treat as entry .

I try it ,but it will build one same code into every target bundle.js, not different files different bundle

var webpackOptions={
    //watch:true,
    output: {
        //path: __dirname+'/index',
        filename: "bundle.js"
    },
    module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" },
            { test: /\.html$/, loader: "html" },
            { test: /\.png/, loader: 'url?limit=100000&minetype=image/png' },
            {
                test: /\.jsx?$/,
                exclude: /(node_modules|bower_components)/,
                loader: 'babel?optional[]=runtime&stage=0'
            },
            //{ test: /\.coffee$/, loader: "coffee-loader" },
            //{ test: /\.(coffee\.md|litcoffee)$/, loader: "coffee-loader?literate" },
            { test: /\.hbs/, loader: "handlebars-loader" }
        ]
    },
    publicPath:'./js',
    alias:{
        lodash:'js/lodash_modern.js'
    }
};


gulp.task('watch',function(){
    var files = getFiles(paths.src);
    var jsTasks=files.jsFiles.map(function(file) {
        var fileName=path.basename(file,'.js');
        return gulp.src(file)
            .pipe(print(function(filePath){
                return "entry: " + filePath;
            }))
            .pipe(webpack(webpackOptions))
            .pipe(gulp.dest(path.dirname(file)))
            .pipe(print(function(filePath){
                return "build: " + filePath;
            }));
    });

    return merge(jsTasks);
});

How do you handle errors in broken stream?

I'm trying to use plumber to handle the errors. If compilation fails during watch, plumber keeps the pipe together, but webpack watch zombies out.

var gulp = require('gulp');
var webpack = require('webpack-stream');
var path = require('path');
var plumber = require('gulp-plumber');

gulp.task('webpack-client', function() {
    return gulp.src(path.join('app/rehydrate'))
        .pipe(plumber())
        .pipe(webpack( require(path.join('../..', 'webpack.config.js'))[0] ))
        .pipe(gulp.dest(path.join('public/dist')));
});

Crash when passing no arguments

Issue

When you pass no arguments to the webpack function it currently crashes;

webpack = require('webpack-stream');

webpack(); // crashes

Cause:

// exports
module.exports = function (options, wp, done) {
  options = clone(options) || {};

// clone
function clone (source) {
  var target = {};

  //!!!! this line will die when source is undefined !!!!
  Object.keys(source).forEach(function (key) {
    target[key] = source[key];
  });

  return target;
}

Possible fixes:

// exports
module.exports = function (options, wp, done) {
  options = options ? clone(options) || {}

// inside clone
function clone (source) {
  if(!source) {
   return source;
 }
  var target = {};
  Object.keys(source).forEach(function (key) {
    target[key] = source[key];
  });

  return target;
}

// more robust 'clone'
function clone(source) {
  return JSON.parse(JSON.stringify(source));
}

Plumber won't work

When error happening plumber doesn't say anything

var plumberErrors = function(err) {
  notify.onError({
    title    : 'Gulp',
    subtitle : 'Failure!',
    message  : 'Error: <%= error.message %>',
    sound    : 'Bee'
  })(err);

  this.emit('end');
};

....

    .pipe(plumber({errorHandler : plumberErrors}))
    .pipe(webpack({
      watch         : true,
      devtool       : 'source-map',
      entry         : {
        profile : './pages/profile.js',
        feed    : './pages/feed.js'
      },
...

Multiple watchers

I want to run multiple watchers, i have 2 separate webpack entries with both other configurations + my regular gulp watch tasks. When i run the webpack tasks with watch: true, it hangs on the first task.

If i disable the watch argument, everything runs fine, but then i loose the awesome caching (quick rebuild) feature of webpack.

[Issue] Gulp Webpack Ignore content and Read By Path

Hello, how are you guys doing?

As mentioned here #47

Gulp webpack are ignoring the stream and read the file by the path.
For doing this, we have to assume the gulp-webpack pipe will be first always. Because it will ignore any previous changes.
And by doing we lose potential, like this module i made, but don't work because of this.

Can i change it?

Edit 10/05

Based on the webpack documentation
http://webpack.github.io/docs/configuration.html#entry

The entry options only can be a path.
So, the problem is not on gulp-webpack, but in this dependencie (webpack).

The way to add a glob wildcard, is in the entry like this

return gulp.src([options.src + '/app/index.js',options.src + '/app/lib/*.js']) //<<<<<<
            .pipe($.webpack(webpackOptions, null, webpackChangeHandler))
            .pipe(gulp.dest(options.tmp + '/serve/app'));

Closed

Add a `watch` option. E.g. webpack({watch: true})

With this flag set to true, the plugin would run bundler in a watch mode - bundler.watch(..), instead of bundler.run(..).

var gulp = require('gulp');
var webpack = require('gulp-webpack');

gulp.task('bundle', function () {
  return gulp.src('src/app.jsx')
    .pipe(webpack({watch: true}))
    .pipe(gulp.dest('./build'));
});

Files are read from file system instead vinyl

I'm using webpack-stream with gulp-preprocess, and in some file I have a someVar = /* @echo CONFIG */ which is processed by gulp-preprocess and become someVar = { foo: "bar" } in order to expose the configuration to the client.
But I noticed that webpack-stream is just reading the contents from the original file in the file system instead the processed, so babel-loader gives syntax error, since someVar = /* @echo CONFIG */ is not valid javascript.

I created this sample repo to easily reproduce the problem.

Question: why use this?

Hi, this may sound like a stupid question but I'm just wondering why we would use this instead of the webpack cli or api? It seems like with the webpack config we can already specify the entry points and outputs. With the gulp plugin we'd have to specify it again with gulp.src and gulp.dest. Is there some benefit for using this plugin?

Path ignored when async loading

I have this gulp task:

/**
 * Webpack
 */
gulp.task('webpack', function() {
    return  gulp.src(app+'js/entry.js')
    .pipe(plumber())
    .pipe(webpack({
        path: '/dist',

        entry: app+'js/entry.js',
        output: {
            filename: '[name].js',
        },
        externals: {
            // require("jquery") is external and available on the global var jQuery
            "jquery": "jQuery",
        },
        devtool: "source-map",
    }))
    //.pipe(uglify())
    .pipe(gulp.dest(dist+'js'));
});

in the entry.js are some external chunks, that will be loaded conditional.

require.ensure([], function(require) {
    require("./chunk/script.js");
}, 'common');

several .js files are generated.
On the website main.js loads fine.
Conditional chunks not.
Webpack main.js file tries to load from root, not from the path set.

Is there a bug, or did I get something wrong?

expose more stats flags

Could you please expose more stats flags?

version
cached
cachedAssets
reasons
source
errorDetails

Manually specifying entry points vs gulp.src

Hi,
I see that recently you've added

// If entry point manually specified, trigger that
if (options.entry) {
  stream.end();
}

and that actually does fail in my setup with manual entry points via config with this exception

node_modules/gulp-webpack/index.js:44
    entry.push(file.path);
          ^
TypeError: Cannot call method 'push' of undefined

What is the supposed general workflow for gulp-webpack?
I guess options.entry take precedence over gulp.src and it did work until recently (before if (options.entry) stream.end() was added).

Am I missing anything?

unmask webpack module

Sometimes it's necessary to have a link to the inner webpack module.
Here is a real-life example:

gulp.task('webpack', ['dist'],
    function () {
        return gulp.src('test/units/**/*.js')
            .pipe(plumber())
            .pipe(webpack({
                output: {
                    filename: 'build.js',
                    pathinfo: true,
                    sourcePrefix: '\t\t\t'
                },
                devtool: 'source-map',
                plugins: [
                    // fix compilation persistence
                    new webpack.optimize.OccurenceOrderPlugin(true)
                ]
            }))
            .pipe(gulp.dest('test'));
    }
);

It will fail trying to use the given plugin new webpack.optimize.OccurenceOrderPlugin(true) as webpack here is an instance of gulp-webpack.
It would be nice to have a link to be able to write something like this:
new webpack.webpack.optimize.OccurenceOrderPlugin(true)

Error with latest version of webpack: compiler has no method 'plugin'

Anyone else getting the following error when updating to the latest version of WebPack?

/Users/anthonyvanderhoorn/Projects/glimpse/glimpse.client/node_modules/gulp-webpack/index.js:54
    compiler.plugin('after-emit', function(compilation, callback) {
             ^
TypeError: Object #<Watching> has no method 'plugin'
    at Stream.<anonymous> (/Users/anthonyvanderhoorn/Projects/glimpse/glimpse.client/node_modules/gulp-webpack/index.js:54:14)
    at _end (/Users/anthonyvanderhoorn/Projects/glimpse/glimpse.client/node_modules/gulp-webpack/node_modules/through/index.js:65:9)
    at Stream.stream.end (/Users/anthonyvanderhoorn/Projects/glimpse/glimpse.client/node_modules/gulp-webpack/node_modules/through/index.js:74:5)
    at DestroyableTransform.onend (/Users/anthonyvanderhoorn/Projects/glimpse/glimpse.client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:523:10)
    at DestroyableTransform.g (events.js:180:16)
    at DestroyableTransform.emit (events.js:117:20)
    at /Users/anthonyvanderhoorn/Projects/glimpse/glimpse.client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:965:16
    at process._tickCallback (node.js:419:13)

[bug?] Piping not working when watch is true

Type: bug (maybe)

What happens: Piping from webpack-stream to, say, gulp-concat isn't working when watch is set to true.

Steps to reproduce

  1. Set up webpack-stream to accept n entries using either method in this project's README
  2. Ensure that watch isn't on, and pipe the output to gulp-concat.
  3. Observe that it works
  4. Turn on watch
  5. Observe that it doesn't work

Possible cause: This might have to do with the internals of webpack's watch changing what is sent out from the pipe? I'm not sure – gotta investigate that.

Why am I doing this?

This is likely me being a goof somewhere. My set up is that I've got n independent test files for a library. I want to build them with webpack into a single file that can be loaded into the browser.

Afaik webpack doesn't support n entry points into 1 file; each independent entry point is converted into its own "chunk." For this reason, I'm piping webpack into gulp-concat to produce a single file to load up in the browser.

I don't want to manually maintain a list of test files, so somewhere along the line I've got to glob. I guess the two options are:

  1. somehow set up a require(); in my code that allows for globbing
  2. set up globbing when specifying my target files, then concatenating them

Option 1 seemed like more work (the glob-loader plugin isn't very feature-ful...no source maps, for instance), so I was trying to do option 2.

Is this silly? : P

I'll do my best to investigate this, but I figured I'd raise the issue in case anyone happens to know what the issue is.

p.s. super awesome library here, @shama!

Expose original 'done' function

Hello,

I need to call browser-sync in 'done' callback and I would like to do this in addition to the original 'done' callback which performs quite a lot useful stuff. However, current API leaves me no other choice but to replace original done callback without a way to do a "super" call. It would be great if original done function (starting at https://github.com/shama/gulp-webpack/blob/master/index.js#L30) would either be publicly exposed or passed to the overriding 'done' as third parameter.

The example doesn't work in 2.1.0

The very first example in the documentation fails in 2.1.0 with the following error.

TypeError: Object.keys called on non-object
    at Function.keys (native)
    at clone (/.../node_modules/webpack-stream/index.js:170:10)
    at module.exports (/.../node_modules/webpack-stream/index.js:26:13)
    at Gulp.<anonymous> (/.../gulpfile.js:6:11)
    at module.exports (/.../node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/.../node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/.../node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/.../node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at /usr/local/lib/node_modules/gulp/bin/gulp.js:121:20
    at process._tickCallback (node.js:415:13)

This is because options is passed to Object.keys without checking whether it's an object and it's undefined in this case.

Multiple entries

Is there a more gulp-y way to do multiple entry points rather than using the webpack entry option? As I understand it, using the entry option makes the gulp.src kind of irrelevant?

Multiple entry files with the same name

Hi!

I am trying to feed webpack stream with multiple index.coffee files, I use vinyl-named + output:{filename: '[name].js' }, so I get multiple files, but unfortunately their content is the same. I guess this is because of

The above named() stream will add a .named property to the vinyl files passing through. The webpack() stream will read those as entry points and even group entry points with common names together.

So how can I handle it?

Does not work with webpack watch

I'm trying to use gulp-webpack along with webpack's watch option. Doing so produces this error:

compiler.plugin('after-emit', function(compilation, callback) {
             ^
TypeError: Object #<Watching> has no method 'plugin'
    at Stream.<anonymous> (node_modules/gulp-webpack/index.js:54:14)

My use case here is monitoring my source and test files for changes and automatically running the tests when things change. I could have gulp do the watching but I'd rather rely on webpack to figure out what to watch if possible.

Webpack ignore the stream

Hi there!

I'm trying to use gulp-include then gulp-webpack ...but not succeed for now.
It seems to ignore the include part... (I see my //= require ./thing.js in the bundled file).

Is anyone know how to fix this?

JS task:
gulp.src(config.src_dir + '/js/main.js')
        .pipe($.include())
        .pipe($.webpack(config.webpack))

        .pipe(gulp.dest(config.public_dir + '/js'));
main.js
console.log('-> main');

// gulp-include:
//= require ./yepee.js
yepee.js
console.log('ᕕ( ᐛ )ᕗ <( Yepee! )');

Errors in `webpack` break the pipe / task

Hello,

I am using webpack and gulp to build a coffee-script app using webpack watch option.

Any coffee-loader error, such as a syntax error, will just crash webpack along with gulp.

Using plumber or anything to catch the error will prevent gulp from crashing but won't keep webpack alive.

How can we fix that?

The base options for src aren't being honored

Even when my files are in folders below the assets path, the output is always spit out to the assets path. For example, if my assets path is '/assets/' and my entry point is at '/assets/js/main.js', the output should be back in the js folder, but it's always in the assets folder.

function compileWebpack() {
    return gulp.src(config.webpack.entryPoints, { base: config.paths.assets })
        .pipe(webpack({
            output: {
                filename: '[name].bundle.js'
            },
            devtool: '#source-map'
        }))
        .pipe(gulp.dest(config.paths.assets));
}

Checking for no input files breaks using the entry configuration parameter.

In 0.4.0, the change to stop when there are no input files (#15) prevents us from using the entry configuration parameter in our webpack config.

This is my gulp task:

gulp.task('js', function() {

    var webpackConfig = {
        context: __dirname,
    entry: {
        "app": "./js/app.js"
        },
        output: {
            path: path.join(__dirname, ".."),
            filename: "/js/[name].js",
            chunkFilename: "/js/[id].js",
        },
        plugins: [
            new CommonsChunkPlugin("/js/common.js"),
            new webpack.ResolverPlugin(
                new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
            )
        ]
    };

    return plugins.webpack(webpackConfig)
        .pipe(gulp.dest('../'));
});

If I comment out line 55 to 58 in index.js, compilation works correctly.

File doesn't exist error when output file has "?"

I have a webpack configuration that writes the hash as a querystring for all chunks to be used as a cache-buster like so:

module.exports = {
    entry: "index.js",
    output: {
        chunkFilename: "chunks/chunk.[id].js?[hash]
    }
}

This setup works when using webpack directly; the files are emitted without the querystring and the requireEnsure() contains the hash.

However, when I switched to gulp-webpack, I get an error:

[12:22:31] Starting 'scripts'...

c:\project\node_modules\gulp-webpack\node_modules\memory-fs\lib\MemoryFileSystem.js:82
                        throw new Error("File doesn't exists " + _path);
                              ^
Error: File doesn't exists /tmp/chunks/chunk.1.js?f63abfa80e027b171a35
    at MemoryFileSystem.readFileSync (c:\project\node_modules\gulp-webpack\node_modules\memory-fs\lib\MemoryFileSystem.js:82:10)
    at module.exports (c:\project\node_modules\gulp-webpack\index.js:107:29)
    at Array.forEach (native)
    at Tapable.module.exports (c:\project\node_modules\gulp-webpack\index.js:104:39)
    at Tapable.applyPluginsAsync (c:\project\node_modules\webpack\node_modules\tapable\lib\Tapable.js:73:13)
    at Tapable.afterEmit (c:\project\node_modules\webpack\lib\Compiler.js:267:8)
    at Tapable.Compiler.emitAssets (c:\project\node_modules\webpack\lib\Compiler.js:262:14)
    at done (c:\project\node_modules\webpack\node_modules\async\lib\async.js:135:19)
    at _toString (c:\project\node_modules\webpack\node_modules\async\lib\async.js:32:16)
    at MemoryFileSystem.writeFile (c:\project\node_modules\gulp-webpack\node_modules\memory-fs\lib\MemoryFileSystem.js:220:9)

It looks like the memory-fs module is trying to locate the file with the querystring appended.

can not find the source map file when use UglifyJsPlugin

gulp.task('test', function() {
    gulp.src('frontends/scripts/index.js')
        .pipe(webpack({
            plugins: [
                new webpack.webpack.optimize.UglifyJsPlugin({ minimize: true, sourceMap: true })
            ]
        }))
        .pipe(rename("index.min.js"))
        .pipe(gulp.dest('frontends/build/scripts/'));
});

The index.min.js is created and minified properly, but I can not find any source map file.
And there is no //# sourceMappingURL=index.min.map at the end of index.min.js file.
Considering UglifyJsPlugin does have sourceMap option, is this a bug of webpack-stream?

Issue with empty source streams

I get an uhandled stream error, if the source stream is empty. This could happen, if for some circumstance the source glob pattern isn't matching any files.

Setup

var gulp = require('gulp');
var webpack = require('gulp-webpack');
var debug = require('gulp-debug');
gulp.task('default', function() {
    return gulp.src('path/to/nothing')
        .pipe(debug())
        .pipe(webpack())
        .pipe(gulp.dest('dist/'));
});

Error

stream.js:94
    throw er; // Unhandled stream error in pipe.

Error: Path doesn't exist '/vagrant/412d142f659f7fef34e4.js'
at MemoryFileSystem.writeFileSync (/vagrant/node_modules/gulp-webpack/node_modules/memory-fs/lib/MemoryFileSystem.js:175:10)
at MemoryFileSystem.writeFile (/vagrant/node_modules/gulp-webpack/node_modules/memory-fs/lib/MemoryFileSystem.js:220:8)
at Tapable.writeOut (/vagrant/node_modules/webpack/lib/Compiler.js:258:27)
at Tapable.<anonymous> (/vagrant/node_modules/webpack/lib/Compiler.js:244:20)
at /vagrant/node_modules/webpack/node_modules/async/lib/async.js:125:13
at Array.forEach (native)
at _each (/vagrant/node_modules/webpack/node_modules/async/lib/async.js:46:24)
at Object.async.each (/vagrant/node_modules/webpack/node_modules/async/lib/async.js:124:9)
at Tapable.emitFiles (/vagrant/node_modules/webpack/lib/Compiler.js:233:20)
at /vagrant/node_modules/webpack/node_modules/mkdirp/index.js:47:26

Log

gulp-debug: 0 items

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.