lukeed / taskr

A fast, concurrency-focused task automation tool.
MIT License
2.53k stars 75 forks source link

How can I mangle using this plugin ? what should I pass in options ? #308

Closed oronoa closed 6 years ago

oronoa commented 6 years ago

This doesn't work

.uglify({
      compress: {
        conditionals: 1,
        drop_console: 0,
        comparisons: 1,
        join_vars: 1,
        booleans: 1,
        loops: 1
      },
      mangle: {
        reserved:['require']
      },
   }
lukeed commented 6 years ago

Hey~! May I see the rest of your task?

oronoa commented 6 years ago

Sure , it's taken from the hyperapp boilerplate project

export async function release(taskr) {
  await taskr
    .source(`${target}/*.js`)
    .uglify({
      compress: {
        conditionals: 1,
        drop_console: 0,
        comparisons: 1,
        join_vars: 1,
        booleans: 1,
        loops: 1
      },
      mangle: {
        reserved:['require']
      },
      'mangle-props' : {
        keep_quoted : 1
      }
    })
    .target(target)
  await taskr
    .source(`${target}/**/*`)
    .rev({
      ignores: ['.html', '.json', '.txt']
    })
    .revManifest({ dest: releaseTarget, trim: target })
    .revReplace()
    .target(releaseTarget)
  await taskr
    .source(`${releaseTarget}/*.html`)
    .htmlmin()
    .target(releaseTarget)
  await taskr
    .source(`${releaseTarget}/*.html`)
    .shell(`sed -i -- 's/__TITLE__/${site_const.title}/g' $file`)
    .shell(`sed -i -- 's/__CDN__/${cdn}/g' $file`)
  await taskr
    .source(`${releaseTarget}/**/*.{js,css,html,png,jpg,gif}`)
    .precache({ stripPrefix: `${releaseTarget}/` })
    .target(releaseTarget)
}
lukeed commented 6 years ago

Thanks! What errors do you see?

oronoa commented 6 years ago

none, but I don't see my function names / properties mangled .. so something is wrong

lukeed commented 6 years ago

The @taskr/uglify pkg is outdated as it's still using Uglify 2.x

You'll have to change the mangle config you have to use the 2.x config.

I'd first just use mangle:true to verify that it's working before adding in customizations.

oronoa commented 6 years ago

Yep, mangle works thx! however --mangle-props i.e 'mangle-props' : true, doesn't

lukeed commented 6 years ago

I've no idea 😬 I'm pretty sure mangle-props is only meant to be an object, while mangle can take multiple definition types.

Will close this for now, but updating (all) packages is on my TODO list.

Thanks!