qrohlf / trianglify

Algorithmically generated triangle art
http://qrohlf.com/trianglify/
GNU General Public License v3.0
10.08k stars 669 forks source link

Non-minified javascript bundle creation? #115

Closed datermine closed 4 years ago

datermine commented 4 years ago

Hello! I'm a big fan of this project!

I'd like to use it in a browser add-on, but Chrome extensions can't have minified javascript included.

I tried to clone and submit a PR for this, but I don't have Cairo installed, so I'm proposing a new Gulp/Browserfy/whatever rule be created that bundles without minifying and adds it to dist/

Thoughts?

qrohlf commented 4 years ago

For one thing, I'd suggest using some kind of bundler for building your Chrome extension if you're going to be pulling in external dependencies.

If you're sure that a non-minified, but bundled-with-dependencies build of Trianglify is what you want, I would pull down the next branch (https://github.com/qrohlf/trianglify/tree/next), build it (npm run build), and play around with the settings being passed into microbundle until you get what you need.

Worth noting: the options passed in to the next branch are camelCase now rather than snake_case

datermine commented 4 years ago

Well...I'm not sure how much they'd like the big ol' bundle of code, tbh:

"Starting today, Chrome Web Store will no longer allow extensions with obfuscated code. " https://blog.chromium.org/2018/10/trustworthy-chrome-extensions-by-default.html

I ended up checking out master and adding this to the gulp file:

gulp.task('browserify-no-min', ['jshint'], function() {
  // start the deps bundler
  return bundler.bundle()
    .on('error', function(error) {
      notifier.notify({
        'title': 'Browserify Build Failed',
        'message': path.relative(__dirname, error.filename)
      });
      console.log(error.message);
      this.emit('end');
    })
    .pipe(source('./trianglify.bundle.js'))
    .pipe(buffer())
    .pipe(gulp.dest('dist'));
});

That meets my requirements. Generally having an unminified bundle in dist/ might be nice for other folks though.

qrohlf commented 4 years ago

Cool, glad you got it working. FYI, I think you may be confusing minification with obfuscation. The former is allowed and even recommended for Chrome Web Store content, the latter is not:

(https://blog.chromium.org/2018/10/trustworthy-chrome-extensions-by-default.html)

datermine commented 4 years ago

Interesting. Thanks Quinn!