2017-06-12 20 views
4

我想使用由WebClip Closure编译器生成的SourceMaps,但我不知道该怎么做。webpack +闭包编译器中的源映射

这里是我的WebPack配置:

const ClosureCompiler = require('google-closure-compiler-js').webpack; 

module.exports = { 
    devtool: 'source-map', 
    entry: './src/app.js', 
    output: { 
     path: __dirname + "/build/", 
     filename: "bundle.js", 
     //sourceMapFilename: "./app.js.map", 
    }, 
    plugins: [ 
     new ClosureCompiler({ 
      compiler: { 
       language_in: 'ECMASCRIPT5', 
       language_out: 'ECMASCRIPT5', 
       compilation_level: 'ADVANCED', 
       create_source_map: __dirname + './output.js.map' 
      }, 
      concurrency: 3, 
     }) 
    ] 
}; 

当我运行的WebPack,没有发生。为什么?我究竟做错了什么? 谢谢你的帮助。

回答

0

使用最新版本的谷歌闭合,编译器的JS(20170910.0.1),我是能够得到它使用下列选项工作:

plugins: [ 
    new ClosureCompiler({ 
    options: { 
     languageIn: 'ECMASCRIPT6', 
     languageOut: 'ECMASCRIPT5', 
     compilationLevel: 'ADVANCED', 
     createSourceMap: true 
    } 
    }) 
]