All Projects → ssrwpo → uglifyjs2

ssrwpo / uglifyjs2

Licence: MIT License
Meteor package that exposes options for UglifyJS2 JS minifier

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to uglifyjs2

Dermatron
Dermatology focused medical records software, augmented with computer vision and artificial intelligence [Meteor packaged with Electron]
Stars: ✭ 19 (+26.67%)
Mutual labels:  meteor
meteor-getting-started
Урок для хабры. Разработка первого метеор приложения.
Stars: ✭ 36 (+140%)
Mutual labels:  meteor
spiderable-middleware
🤖 Prerendering for JavaScript powered websites. Great solution for PWAs (Progressive Web Apps), SPAs (Single Page Applications), and other websites based on top of front-end JavaScript frameworks
Stars: ✭ 29 (+93.33%)
Mutual labels:  meteor
Meteor-Remember-Me
Meteor accounts extension with remember me functionality
Stars: ✭ 13 (-13.33%)
Mutual labels:  meteor
meteor-publication-collector
Test a Meteor publication by collecting its output.
Stars: ✭ 32 (+113.33%)
Mutual labels:  meteor
accessibility-cloud
👩🏽‍🦯🦮👩🏻‍🦽👩🏿‍🦼 the platform to exchange physical accessibility data in a standardized, future-proof, easy-to-use way.
Stars: ✭ 37 (+146.67%)
Mutual labels:  meteor
meteor-vuetify
Experimenting with using Vuetify on a Meteor project.
Stars: ✭ 18 (+20%)
Mutual labels:  meteor
ReaDB
ReaDB is your private digital bookshelf. Read. Review. Remember.
Stars: ✭ 84 (+460%)
Mutual labels:  meteor
meteor-spacebars-tohtml
Meteor package to ease rendering spacebars to html
Stars: ✭ 35 (+133.33%)
Mutual labels:  meteor
awesome-blaze
🔥A curated list of awesome things related to Blaze
Stars: ✭ 29 (+93.33%)
Mutual labels:  meteor
polytunes
An collaborative music game using Meteor and Web Audio
Stars: ✭ 23 (+53.33%)
Mutual labels:  meteor
blaze-magic-events
A new way of binding event handlers to html elements for Meteor's Blaze.
Stars: ✭ 26 (+73.33%)
Mutual labels:  meteor
meteor-autoform-materialize
DEPRECATED - Meteor AutoForm Materialize templates
Stars: ✭ 48 (+220%)
Mutual labels:  meteor
meteor-google-spreadsheets
Google Spreadsheets for Meteor
Stars: ✭ 53 (+253.33%)
Mutual labels:  meteor
TorrentsDuck
A multi users bittorrents client with a responsive web UI that quacks 🦆
Stars: ✭ 42 (+180%)
Mutual labels:  meteor
svelte-meteor-data
Reactively track Meteor data inside Svelte components
Stars: ✭ 14 (-6.67%)
Mutual labels:  meteor
meteor-auth0
Auth0 Login Flow for Meteor apps
Stars: ✭ 20 (+33.33%)
Mutual labels:  meteor
sofie-core
Sofie: The Modern TV News Studio Automation System (Server Core)
Stars: ✭ 70 (+366.67%)
Mutual labels:  meteor
meteor-guide-starter-react
A basic starter application based on the Meteor guide
Stars: ✭ 20 (+33.33%)
Mutual labels:  meteor
accounts-material-ui
Material-ui integration with std:accounts-ui
Stars: ✭ 17 (+13.33%)
Mutual labels:  meteor

Description

A JS minifier with more aggressive set of default options. Options are configurable in your project's package.json.

Interesting side effect This package increases security by removing part of your server side code which is normally included by the Meteor's standard minifier.

Usage

meteor remove standard-minifier-js
meteor add ssrwpo:uglifyjs2

Configuration

Default options

The following default options are activated:

uglifyjs2: {
  deadCodes: [
    '_meteor.Meteor.isServer',
    'Meteor.isServer'
  ],
  fileRemoval: [
    'packages/ddp-server.js',
    'packages/shell-server.js',
    'packages/ssrwpo_uglifyjs2.js'
  ],
  packageDebug: false,
  options: {
    fromString: true,
    compress: {
      properties: true,
      dead_code: true,
      drop_debugger: true,
      conditionals: true,
      comparisons: true,
      evaluate: true,
      booleans: true,
      loops: true,
      unused: true,
      hoist_funs: true,
      if_return: true,
      join_vars: true,
      cascade: true,
      collapse_vars: true,
      negate_iife: true,
      pure_getters: true,
      drop_console: true,
      keep_fargs: false,
      keep_fnames: false,
      passes: 2,
      global_defs: {
        UGLYFYJS_DEAD: false
      }
    }
  }
}

Dead code elimination

deadCodes is a list of Strings is used for text replacement as a global definition transformed into UGLYFYJS_DEAD allowing minifications with dead code removal. This acts as macro for code removal in your project.

In your package.json, add the deadCodes option to additional dead code removals:

"uglifyjs2": {
  ...
  "deadCodes": ["Meteor.isServer", ...],
  ...
}

By default, the list only contains: ['Meteor.isServer'].

UglifyJS2 options

Overwrite the default options to add or remove UglifyJS2's options.

In your package.json, add the options for tweaking UglifyJS2's options:

"uglifyjs2": {
  ...
  "options": {
    "fromString": true,
    "compress": {
      ...
      "properties": false,
      ...
    }
  }
  ...
}

⚠️ Meteor relies on text analysis when using UglifyJS2. Therefore, removing the fromString option leads to unexpected results.

Development minification

Meteor's standard minifier skip minification while in development. As dead code removal could affect your project's behavior, this package allows you to minify your code while developping.

In your package.json, add the development option to activate minification while in development mode:

"uglifyjs2": {
  ...
  "development": true,
  ...
}

Package debug options

This adds some debug informations while processing production build. It helps tracking the files that will get included into the web bundle JS file.

For activating it, simply add the packageDebug option in your package.json.

"uglifyjs2": {
  ...
  "packageDebug": true,
  ...
}

File removals

Meteor injects files in the client that doesn't belong to the client. This is used by Meteor to display informations on used packages in the server. Removing these informations increase security and removes some unecessary lost bytes.

Some defaults files are removed automatically with this package and you can tweak these removals using fileRemoval options in your package.json.

"uglifyjs2": {
  ...
  "fileRemoval": [
    "packages/ddp-server.js",
    "packages/shell-server.js",
    "packages/ssrwpo_uglifyjs2.js"
  ],
  ...
}

Aggressive minification

By default, minification is done file by file. Aggressive minification aggregates all files and then apply the minification allowing UglifyJS2 to go a little bit further in its optimization.

Turned off by default, this option can be added using the aggressive flag in your package.json.

"uglifyjs2": {
  ...
  "aggressive": true,
  ...
}

Package development

Exported symbols

This package exports a function loadPackageJson that parses the content of then NPM's package.json file of a Meteor project.

Dependencies & demo project

At the root of the repository:

yarn install
cd demo
yarn install
# Launch the demo in development mode
yarn dev
# Launch the demo in production mode
yarn prod

Tips

  • My build process is stucked at "Minifying app code": meteor reset.
  • Start with a small project when choosing your options.
  • Don't add reduce_vars as option as it prevents Meteor from starting.
  • Use the default options as a canevas for experimenting additional UglifyJS2 options.

Links

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].