我们正在使用webpack捆绑我们的JavaScript& jsx文件,我们使用Gulp运行运行webpack。我们已经指定了devtool: 'source-map'
选项,当gulp运行时,我们会看到bundle.js.map
被发出,但是当我们查看目标文件夹时,它不在那里。 (bundle.js
就在那里)。有谁知道这里发生了什么?
这是我们的webpack.config.js
var path = require('path');
var webpack = require('webpack');
module.exports = {
context: path.resolve('./cdn/source/javascript'),
entry: ['./app'],
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel'
}
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({minimize: true}),
new webpack.NoErrorsPlugin()
],
output: {
path: path.resolve('./cdn/distribution'),
filename: 'bundle.js'
},
devtool: 'source-map'
};
这是我们的一项任务:
gulp.task('scripts', () => {
del(['./cdn/distribution/*.js', './cdn/distribution/*.js.map']);
var webpackconfigjs = require('./webpack.config.js');
return gulp.src('./cdn/source/javascript/app.jsx')
.pipe(webpack(webpackconfigjs))
.pipe(gulp.dest('./cdn/distribution'));
});
这是我们看到的输出:
[11:27:53] Using gulpfile D:\Code\mergeui\gulpfile.js
[11:27:53] Starting 'scripts'...
[11:27:59] Version: webpack 1.12.10
Asset Size Chunks Chunk Names
bundle.js 273 kB 0 [emitted] main
bundle.js.map 2.21 MB 0 [emitted] main