未加星标

Jetpack Webpack made more convenient

字体大小 | |
[前端(javascript) 所属分类 前端(javascript) | 发布者 店小二04 | 时间 2019 | 作者 红领巾 ] 0人收藏点击收藏

Jetpack   Webpack made more convenient
Webpack made more convenient.

Jetpack wraps webpackto create a smoother developer experience. Jetpack can be used instead of webpack, webpack-cli, webpack-dev-server and webpack-dev-middleware without writing any configuration. Jetpack is a thin wrapper around webpack, and can be extended with any of the webpack configuration.

Sensible defaults to handle modern javascript, CSS and images. Preconfigured Babel with @babel/preset-env and @babel/preset-react , configurable via .babelrc . Preconfigured PostCSS with postcss-preset-env including autoprefixing, configurable via postcss.config.js . CSS modules available by switching one config flag. Automatic JSX detection switches between React.createElement or h depending on dependencies. Hot reloading built in for React as well as vanilla JavaScript and CSS. Automatic chunk splitting with inlined runtime and HTML generation. Smooth workflow for simultaneously developing client and server applications Single dependency with hassle-free updates. Run anywhere without installing locally, just like nodemon .

Why use jetpack?To avoid rolling your own custom webpack config or having to paste it from old projects. Jetpack has a set of defaults that should get you off the ground quickly. And with the proxy config or universal jetpack/serve middleware you don't have to worry about wiring up webpack dev middleware or dev server everything just works .

Usage

Install globally or locally:

$ npm install -g jetpack

In your project with package.json or index.js , start your app on http://localhost:3030 :

$ jetpack

To build the app for production to a dist directory:

$ jetpack build

Inspect the bundle size and make up:

$ jetpack inspect Use jetpack anywhere, anytime

One of jetpack goals is to help you run any piece of JavaScript in a browser as easily as it it to run node scripts. Install jetpack globally and point it to any file on your machine. This is an alternative to jsfiddle / codepen / codesandbox style of hacking on things.

$ jetpack ~/Desktop/magic.js

Or any project on your machine:

$ jetpack --dir ~/projects/manyverse Use jetpack with an API

Another goal of jetpack is to assist you in building complete, production apps. Very often in addition to developing the clientside application, you are also developing an API. Jetpack has a few features to make building such apps easier.

Point your package.json#main to your server entry and package.json#browser to your client entry.

Now you can run your API server together with jetpack in a single command:

$ jetpack -x

Alternatively, specify any command to execute: $ jetpack -x 'nodemon ./api'

Use this even if your server is not written in node

$ jetpack -x 'rails s'

Jetpack provides an ability to proxy requests to your api by specifying proxy configuration in jetpack.config.js or mounting the dev server to your application server using the jetpack/serve middleware. Read more about it in Workflow and deployment docs.

Documentation All configuration options Customizing Webpack Customizing Babel Customizing PostCSS Customizing Browserlist Workflow and deployment Hot reloading Comparison to cra, pwa-cli, parcel, etc. Recipes Deploying to Netlify static apps Deploying to Now client and server all in one Deploying to Netlify + Now client and server separated Adding Flow Adding Typescript Server side rendering Your feedback!

This project is an exploration of some ideas accumulated over a few years using webpack in a variety of projects. Webpack is a very powerful and flexible tool. It applies to a lot of use cases and that is one of the reasons it has so many configuration options. Webpack also evolved over the years but preserved backwards compatibility as much as possible to support the large ecosystem built around it.

Jetpack is an exploration of how using webpack could be made easier if the defaults, the CLI usage patterns and the configuration would be different.

I would be very interested in hearing your feedback. You might be new to JavaScript development, you tried jetpack and got stuck with something I'd like to fix that. Or perhaps you're a seasoned webpacker in which case I know you saw some specific aspect you probably didn't like, and I'd like to hear about that too.

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

代码区博客精选文章
分页:12
转载请注明
本文标题:Jetpack Webpack made more convenient
本站链接:https://www.codesec.net/view/628362.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(78)