@optimistdigital/create-frontend
Creates an encapsulated frontend build solution for js-based projects
Last updated 10 days ago by matislepik .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @optimistdigital/create-frontend 
SYNC missed versions from official npm registry.

Create Frontend Build Status

This toolkit generates your project's frontend build system. It uses Webpack under the hood.

Features

  • JS (Babel, Eslint, Core-JS, Flow, JSX). Can import relative to project root: import x from 'client/js/y'
  • SCSS with autoprefixer, normalize.css. Images can be imported relative to project root with tilde: background-image: url('~client/images/logo.svg')
  • Hot reload for development
  • Works with zero configuration, but customization is possible if needed
  • Usable with any backend.
  • .html files are built from /client/html by default, with assets automatically linked.

Usage

  1. In Bash, navigate into your project directory
  2. Type npx @optimistdigital/create-frontend and follow the instructions. You may also specify flags:
    • --template=react - Generates a React boilerplate
    • --template=universal-react - Generates a React boilerplate that renders on client and server (using Node.js). Documentation here
    • -y - Skips user confirmation (assume yes)

CLI

  • npm run dev - Start a webpack server for development
  • npm run build - Build assets for production
  • npm run build:debug - Build assets with debug logs. In JS, __DEBUG__ will be transformed to true

There are also flags to customize the dev environment:

  • npm run dev -- --webpackPort=8000 - Custom port for dev server
  • npm run dev -- --webpackDomain=localhost - Custom domain for dev server
  • npm run dev -- --protocol=https - Run the dev server with https

Configuration

Configuration can be done in two places:

  • In your package.json under the create-frontend property. Since this is a JSON file, not all configuration is going to be possible.
{
    "create-frontend": { "publicDirectory": "public" }
}
  • In the create-frontend.conf.js file that you can create in your project root. Use this if you need more complex expressions or JSON isn't enough.
module.exports = { "publicDirectory": "public" }

Here are all the options (default in parens):

  • publicDirectory (public) - Project's public root. Relative to project root.
  • buildPath (build) - Where the build files will go. Relative to the public directory.
  • hashFileNames (true) - Whether or not filenames should be hashed in production (e.g app-503dcc37.js). An asset-manifest.json file will be generated either way.
  • htmlPath (client/html) - Html files from this directory will be built into the public directory with html-webpack-plugin.
  • htmlOptions ({}) - Options that will get passed to html-webpack-plugin
  • entryPoints - Object/string/array that contains the entry points for your application. Relative to project root. Default:
    {
        app: 'client/js/entry.js',
    }
    
  • appendPlugins - Function that returns an array of Webpack plugins. Appended to the end of the plugins array.
  • prependRules - Function that returns an array of Webpack rules. The first one to match will be used (oneOf). These take precedence over default rules - if your custom rule matches, the default ones will not be used.
  • editConfig - Function that can be used to return a customized version of the Webpack config. First argument is the webpack config that is generated by Create Frontend. Use this as an escape hatch to customize the Webpack config directly.
  • editDevServerConfig - Function that can be used to return a customized version of the Webpack Dev Server config.

The opts parameter contains the following object: { IS_PRODUCTION: boolean, paths: Object, config: Object }

Configuring Babel

If you need to make changes to the babel config, you can extend our babel preset by making a configuration file in your project root:

  • In babel.config.js
const config = require('@optimistdigital/create-frontend/babel-config');
/* Make adjustments */
module.exports = config;
  • In .babelrc
{
    "extends": "@optimistdigital/create-frontend/babel-config.js"
}

Using hot module replacement

Hot module replacement is enabled for the app, however you must choose manually what you want to update when changes are made. To do this, go into your entry.js file and uncomment the relevant code.

Updating

To update the local version of the toolkit, type npm install @optimistdigital/create-frontend. Please look at the changelog to see if there are any breaking changes.

The global version can be updated with npm install -g @optimistdigital/create-frontend, and will ensure that newly created projects use the latest version.

Current Tags

  • 11.0.0-beta.0                                ...           beta (3 months ago)
  • 13.0.1                                ...           latest (10 days ago)
  • 5.0.0-beta2                                ...           next (a year ago)

59 Versions

  • 13.0.1                                ...           10 days ago
  • 13.0.0                                ...           10 days ago
  • 12.0.2                                ...           16 days ago
  • 12.0.1                                ...           16 days ago
  • 12.0.0                                ...           17 days ago
  • 11.1.0                                ...           2 months ago
  • 11.0.2                                ...           2 months ago
  • 11.0.1                                ...           3 months ago
  • 11.0.0                                ...           3 months ago
  • 11.0.0-beta.0                                ...           3 months ago
  • 10.0.1                                ...           3 months ago
  • 10.0.0                                ...           4 months ago
  • 9.1.1                                ...           4 months ago
  • 9.1.0                                ...           4 months ago
  • 9.0.2                                ...           5 months ago
  • 9.0.1                                ...           5 months ago
  • 9.0.0                                ...           5 months ago
  • 8.1.1                                ...           6 months ago
  • 8.1.0                                ...           6 months ago
  • 8.1.0-beta.1                                ...           6 months ago
  • 8.1.0-beta.0                                ...           6 months ago
  • 8.0.3                                ...           6 months ago
  • 8.0.2                                ...           6 months ago
  • 8.0.1                                ...           6 months ago
  • 8.0.0                                ...           6 months ago
  • 8.0.0-beta.1                                ...           6 months ago
  • 8.0.0-beta.0                                ...           6 months ago
  • 7.0.0                                ...           7 months ago
  • 6.1.0                                ...           10 months ago
  • 6.0.1                                ...           10 months ago
  • 6.0.0                                ...           10 months ago
  • 6.0.0-beta.0                                ...           10 months ago
  • 5.1.2                                ...           a year ago
  • 5.1.1                                ...           a year ago
  • 5.1.0                                ...           a year ago
  • 5.0.0                                ...           a year ago
  • 5.0.0-beta2                                ...           a year ago
  • 5.0.0-beta1                                ...           a year ago
  • 4.0.0                                ...           a year ago
  • 3.1.0                                ...           2 years ago
  • 3.0.1                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.4.1                                ...           2 years ago
  • 2.4.0                                ...           2 years ago
  • 2.3.0                                ...           2 years ago
  • 2.2.2                                ...           2 years ago
  • 2.2.1                                ...           2 years ago
  • 2.2.0                                ...           2 years ago
  • 2.1.1                                ...           2 years ago
  • 2.1.0                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.1.2                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Downloads
Today 0
This Week 1
This Month 316
Last Day 0
Last Week 247
Last Month 23
Dependencies (61)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |