Polymer / tools

Polymer Tools Monorepo
BSD 3-Clause "New" or "Revised" License
430 stars 200 forks source link

"polymer build" ignores code transformation CLI flags #2487

Closed hormesiel closed 5 years ago

hormesiel commented 7 years ago

Description

polymer build --bundle --css-minify --html-minify --js-compile --js-minify outputs the same result as polymer build --bundle.

Versions & Environment

Steps to Reproduce

  1. Create an index.html file with the following content :
<!doctype html>
<html lang="fr">
  <head>
    <title>polymer2</title>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">

    <script src="bower_components/webcomponentsjs/webcomponents-loader.js"></script>
    <link rel="import" href="src/polymer2-app.html">
  </head>

  <body>
    <polymer2-app></polymer2-app>
  </body>
</html>
  1. Create a /src/polymer2-app.html file with the following content :
<link rel="import" href="../bower_components/polymer/polymer.html">

<dom-module id="polymer2-app">
  <template>
    <style>
      :host {
        display: block;
      }
    </style>

    <h1>polymer2-app</h1>
  </template>

  <script>
    class Polymer2App extends Polymer.Element {
      static get is() {
        return 'polymer2-app';
      }
    }

    customElements.define(Polymer2App.is, Polymer2App);
  </script>
</dom-module>
  1. Create a polymer.json file with the following content :
{
  "lint": {
    "rules": [
      "polymer-2"
    ]
  }
}
  1. Build : polymer build --bundle --css-minify --html-minify --js-compile --js-minify

Expected Results

The compiled build/default/index.html file's CSS/HTML/JS content should be minified, and the JS code should be ES5, not ES6.

Actual Results

No minification done, and JS code is in ES6 just like the source files, like if only the --bundle option was taken into account.

Additional information

However it works when I put these build options into polymer.json. And if I pass the --verbose flag I get different debug outputs between passing the flags from the CLI and writing them down in the polymer file.

polymer build --verbose with build options in polymer.json :

debug:   "build/default": Building with options: 
{ bundle: true,
  css: { minify: true },
  html: { minify: true },
  js: { compile: true, minify: true } }

polymer build --bundle --css-minify --html-minify --js-compile --js-minify --verbose :

debug:   "build/default": Building with options: 
{ bundle: true,
  'css-minify': true,
  'html-minify': true,
  'js-compile': true,
  'js-minify': true }

As you can see, build options passed via the CLI are handled differently than options taken from the polymer file.

hormesiel commented 7 years ago

Fixed by #817. Closing.