Tooling: 你不需要再配置 Webpack

2,261 阅读1分钟

Technologies

What tooling supports (which means you don't have to install these dependencies yourself):

  • Webpack
  • Babel 6 + Stage-0 + Runtime
  • React with JSX
  • Vue
  • Vue-loader
  • PostCSS with PreCSS
  • Autoprefixer
  • Hot reloading
  • BrowserSync
  • Custom HTML template
  • Build or Watch
  • Long-term caching

Usage

Installing tooling via NPM is easy (node >= 4.0.0):

Build a project in production mode:

# default entry is ./src/index
tooling build --entry [entry]

Run dev server with hot reloading:

# default entry is ./src/index
tooling watch --entry [entry]

Options:

Argument Description
--entry Set webpack entry, currently single entry only
--port devServer port, available in watch mode
--browsersync Enable browserSync at port 23789
--silent Do not open browser window when running devServer (not work if you enable browserSync)

Set up custom index.html in package.json. see usage at html-webpack-plugin

{
    "name": "My tooling app",
    "tooling": {
        "index": {
          "title": "tooling index",
          "template": "src/index.template"
        }
      }
}

For advanced usage: Wiki

API

npm install tooling --save
import tooling from 'tooling'

/**
 * Tooling
 *
 * @param {string} type - 'watch' or 'build'
 * @param {object} options - options for webpack, 
 *                      - override the default settings.
 *               options.port - available in 'watch' mode
 *                            - to set the port devServer should run at
 */
tooling(type, options)

License

MIT © EGOIST