Giter Club home page Giter Club logo

polymerx-cli's Introduction

PolymerX CLI

Greenkeeper badge

npm

Build Status Build status codecov GitHub issues XO code style PolymerX CLI

Unlock the power of Polymer 3, Web Components and modern web tools.

Features

  • Generate a Polymer Skeleton for your next project in 30 seconds.
  • Build using Webpack 4 under the hood producing Service Worker with WorkboxJs.
  • Develop with ease with hot-reload and error layer enabled.
  • Support for PostCSS (with personal configuration) when getting CSS from external files.
  • https certificate generation on the fly for development.
  • No magic, just using the tools.

More to come...

Install

NOTE: Node.js >= 8.x required.

$ yarn global add polymerx-cli

Or with NPM

$ npm install -g polymerx-cli

Switch from polymer-cli and pwa-starter-kit

If you want to change your builder from the official polymer-cli for pwa-starter-kit to our polymerx-cli you need to make sure your imports are correctly declared without relative path.

Also, you need to make sure your chunksSortMode is set to none for the HtmlWebpackPlugin because a known bug html-webpack-plugin#870.

Create a polymerx.config.js and add the following code:

export default function (config, env, helpers) {
  let { plugin } = helpers.getPluginsByName(config, "HtmlWebpackPlugin")[0];
  plugin.options.chunksSortMode = 'none'
}

Refer to polymerx-cli#179 for more info about the topic.

Templates

Official templates are available at https://github.com/Polymerx-skeleton-templates

Usage

$ polymerx create <template-name> <project-name>

IMPORTANT: currently supported only default as template.

Example:

$ polymerx create default my-awesome-project

CLI commands

⚙️ polymerx create

$ polymerx create --help

  --version   Show version number                                      [boolean]
  --cwd       A directory to use instead of $PWD.                                [default: "."]
  --name      The application's name
  --author    Author of the app                                                  [default: null]
  --force     Force option to create the directory for the new app               [default: false]
  --yarn      Use 'yarn' instead of 'npm'                              [boolean] [default: false]
  --git       Initialize version control using git                     [boolean] [default: false]
  --https     Use HTTPS?                                               [boolean] [default: false]
  --install   Install dependencies                                     [boolean] [default: true]

NOTE: the required data will be asked if not specified.

🕶 polymerx watch

Easy development with hot-reload and "friendly" error layers.

IMPORTANT: postcss configuration file must be present.
$ polymerx watch --help

  --cwd           A directory to use instead of $PWD.              [string]   [default: .]
  --src           Entry file (index.js)                            [string]   [default: "src"]
  --config, -c    Path to custom polymerx.config.js.           [string]   [default: null]
  --port, -p      Port to start a server on                        [string]   [default: "8080"]
  --host,         Hostname to start a server on                    [string]   [default: "0.0.0.0"]

NOTE: You can run the dev server on a different port using PORT=8091 polymerx watch

📦 polymerx build

Create a production build with (or without) Service Workers.

IMPORTANT: postcss configuration file must be present.
$ polymerx build --help

  --cwd             A directory to use instead of $PWD.          [string]   [default: .]
  --src             Entry file (index.js).                       [string]   [default: "src"]
  --dest            Directory root for output.                   [string]   [default: "dist"]
  --config, -c      Path to custom polymerx.config.js.           [string]   [default: null]
  --workers, -w     Add a service worker to application.         [boolean]  [default: true]
  --clean           Clear output directory before building.      [boolean]  [default: true]

Custom Configuration

Webpack

For customizing your webpack configuration create a polymerx.config.js what will exports a function like this:

/**
 * Function that mutates original webpack config.
 * Supports asynchronous changes when promise is returned.
 *
 * @param {object} config - original webpack config.
 * @param {object} env - options passed to CLI.
 * @param {WebpackConfigHelpers} helpers - object with useful helpers when working with config.
 **/
export default function (config, env, helpers) {
  /** you can change config here **/
}

Since we are using the WebpackConfigHelpers by preact-cli you can checkout also their awesome Wiki to get more info about the helper.

About this tool

This CLI is heavily inspired by the awesome preact-cli and aims to became a stable tool for developing Polymer 3 PWA easily and with modern web tools.

License

MIT © LasaleFamine

polymerx-cli's People

Contributors

greenkeeper[bot] avatar lasalefamine avatar zevdg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

polymerx-cli's Issues

Build single component

One component with:

  • index.js
  • style.pcss
  • template.js || template.html

Should be built in one single component.bundle.js.

This can be super useful for testing purposes.

Global installation with yarn no create global command polymerx

I'm working on Windows 10 and after install polymerx-cli (yarn add global polymerx-cli), polymerx command not exist. Moving to (cd command) to node_modules/.bin into folder installation is recognized polymerx. Proccess installation should set path installation (node_modules/.bin) to system variables or explain how execute properly polymerx on Windows.

Ability to modify webpack config

I need the ability to modify how WebPack works. My needs are two-fold:

  1. Ability to have any number of environments beyond prod and dev
  2. Ability to have custom environment variables that I can send to WebPack for use within the build process.

Cyclic dependency error when using "polymerx watch" in a legacy "polymer serve" project

I want to move away from polymer serve because I need something that can build and bundle everything on the fly and that is just not possible with polymer serve. So I was trying to use polymerx (which is SUPER awesome, thank you!!!) and ran into a problem after doing these steps:

  • Created my new project polymerx create default luminave
  • Copied src from the legacy project to the new created one (without index.html)
  • Migrated the changes in index.html manually
  • Executed npm run dev and got this error:
/usr/local/lib/node_modules/polymerx-cli/node_modules/toposort/index.js:35
      throw new Error('Cyclic dependency' + nodeRep)
      ^

Error: Cyclic dependency

This was killing the process and giving me nothing to work with. So I had to create polymerx.config.js, added it to the dev command polymerx watch -c polymerx.config.js with this content:

export default function (config, env, helpers) {
  let { plugin } = helpers.getPluginsByName(config, "HtmlWebpackPlugin")[0];
  plugin.options.chunksSortMode = 'none'
}

This makes sure to disable the chunksSortMode by toposort which is used by the HtmlWebpackPlugin. After this I saw many errors in the console with dependencies that were shit and I could fix all of them.

Now my project is running with polymerx (YAAAAAAAY).

I think it would be nice to mention this somewhere, if someone might want to migrate a "legacy" (a project build on the https://github.com/Polymer/pwa-starter-kit + polymer serve) to use with PolymerX CLI.

Error while installing dependencies when creating a new project

During the "installing dependencies...cli.js create [template] [dest]", i get this error message and it stops.

Node Version: 9.4.0
npm: 5.3.0

{ Error: Command failed: npm install nullnull at makeError (C:\Users\Znipe\AppData\Roaming\npm\node_modules\polymerx-cli\node_modules\execa\index.js:169:9) at Promise.all.then.arr (C:\Users\Znipe\AppData\Roaming\npm\node_modules\polymerx-cli\node_modules\execa\index.js:274:16) at <anonymous> at process._tickCallback (internal/process/next_tick.js:160:7) code: 4294963248, stdout: null, stderr: null, failed: true, signal: null, cmd: 'npm install', timedOut: false, killed: false }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.