Minify: Removing Comments

Created on 23 Oct 2016  路  9Comments  路  Source: babel/minify

Hi,

I'm probably missing something simple here but after getting babili working with my gulp build step the final output is still including comments, is there a particular option I should be setting or is there an expectation to use something else to strip comments?

gulp.src([
  path.join(__dirname, 'src', '**', '*.js'),
  path.join(__dirname, '..', '..', 'lib', '**', '*.js')
])
.pipe(sourcemaps.init())
.pipe(rollup({
  entry: path.join(__dirname, 'src', 'index.js')
}))
.pipe(babel({
  presets: ['babili']
}))
.pipe(sourcemaps.write())
.pipe(rename(pkg.main))
.pipe(gulp.dest(destPath))

Cheers,
Matt

Most helpful comment

Updated solution since the renaming:

// .babelrc
{
  "presets": ["env", "minify"],
  "comments": false
}

All 9 comments

Just put comments: false after presets: ['babili']

how to use comments:false in babel-cli mode?

@cuixiping Passing --no-comments seems to work. Strange that comments: false in .babelrc seems to be ignored by the CLI.

Update: Solved it. I was confused by the docs, but then I understood it 馃槃
Changing my comment, leaving the correct method here.


This is what you should in your .babelrc/package.json

"presets": [
  "babili"
],
"comments": false

what docs?

It does not work either.
Options in different places, some passes to object, some in .babelrc. Options and configurations are scattered throughout the project. It looks like a mess!
Why cant we configure it in Babili options?
Like

.pipe(Babili({
    mangle: { 
        topLevel: true,
        except : [],
        eval : false,
        sort : true,
        screw_ie8 : true,
        keep_fnames : false
    },
    //somewhere here? comments: false,
    deadcode: true,
    removeConsole: false,
}))

@kangax Please reopen, not everyone uses Babili with Babel.

Some people may want to use Babili on it's own, and adding something like Babel just for the purpose of removing comments is completely impractical.

@trusktr answered in #644

Updated solution since the renaming:

// .babelrc
{
  "presets": ["env", "minify"],
  "comments": false
}
Was this page helpful?
0 / 5 - 0 ratings