Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the plugin "DefinePlugin" don't work sometimes #157

Open
zjruan opened this issue Aug 4, 2017 · 0 comments
Open

the plugin "DefinePlugin" don't work sometimes #157

zjruan opened this issue Aug 4, 2017 · 0 comments

Comments

@zjruan
Copy link

zjruan commented Aug 4, 2017

Environment

[webpack-stream:3.2.0] [webpack:3.4.1] [node: 7.9.0|8.2.0] [macOS: 10.12.6 ] [windows:10]

Description

my config like this, but the DefinePlugin don't work sometimes.

work

  • macbook pro, [node: 7.9.0|8.2.0]
  • windows:10, [node: 8.2.0]

don't work

  • macbook Air, [node: 7.9.0|8.2.0]
  • windows:10, [node: 7.9.0]

It's so strange, I try to debug, But it's too time-consuming. So, I changed the version of the webpack that the plugin was dependent to 3.4.1, and it was 1.15.x before.

When I have done this, all things are all right.

Therefore, it may be the webpack-stream depends on a too old webpack version.

So I suggest upgrading the dependent webpack version

// demo: 1
var webpack = require('webpack')
var webpackStream = require('webpack-stream');
/**
 * 编译 js 
 */
gulp.task('compile:js:dev', function(){
	return gulp.src(config.src.js)
		.pipe(named(function(file){
			var relativeName = file.relative;
			return relativeName.replace(path.extname(relativeName), '');
		}))
		.pipe(webpackStream({
			externals: {'$': 'window.$'},
			devtool: 'source-map',
			plugins: [
				new webpack.DefinePlugin({
					STATIC_WEB_PATH: '"//my.test.path"'
				})
			]
		}))
		.pipe(gulp.dest(config.dist.js))
		.pipe(global.browsersync.stream());
});
// demo: 2
// The final solution of me
gulp.task('compile:js:dev', function(){
	return gulp.src(config.src.js)
		....
		.pipe(webpackStream({
			externals: {'$': 'window.$'},
			devtool: 'source-map',
			plugins: [
				new webpack.DefinePlugin({
					STATIC_WEB_PATH: '"//my.test.path"'
				})
			]
		}, webpack))
		...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant