zed
zed

Reputation: 79

Source maps in webpack + closure compiler

I would like to use SourceMaps generated by Closure Compiler using Webpack but I cant figure out how to do it.

Here is my webpack config:

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,
        })
    ]
};

When I run webpack, nothing happen. Why? What am I doing wrong? Thank you for your help.

Upvotes: 4

Views: 686

Answers (1)

Borre Mosch
Borre Mosch

Reputation: 4564

Using the latest version of google-closure-compiler-js (20170910.0.1), I was able to get it to work using the following options:

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

Upvotes: 1

Related Questions