UNPKG

9.91 kBMarkdownView Raw
1[![Build Status](https://travis-ci.org/rei/febs.svg?branch=master)](https://travis-ci.org/rei/febs)
2
3# FEBS
4
5## Summary
6
7`FEBS` is an extensible [webpack](https://webpack.js.org/)\-based [front-end build system](https://engineering.rei.com/frontend/the-rei-front-end-build-system.html)
8designed to be used by a community of front-end developers or a series of projects using a similar set of technologies
9in order to reduce duplicate effort of build configurations.
10
11Its code falls into two categories:
12
13### [Build Features](#build-features)
14
15* [JavaScript](#javascript)
16* [Style](#style)
17* [Source Maps](#source-maps)
18* [Live reloading](#live-reloading)
19* [Code Watching](#code-watching)
20
21### [FEBS core](#febs-core)
22
23- [Command-line interface](#command-line-interface)
24- [Development and production builds](#production-and-development-builds)
25- Produces a [Build Manifest](#build-manifest) so you can insert assets on your page using an [Asset Injector](#asset-injector)
26
27Learn more about [REI's Front-End Build System ](https://engineering.rei.com/frontend/the-rei-front-end-build-system.html)
28by checking out the introductory post on the [REI Co-op Engineering blog](https://engineering.rei.com).
29
30## Getting Started
31
32### Install
33
34#### Install the dependency
35
36`npm install --save @rei/febs` (`--global` switch optional)
37
38#### Assign build tasks
39
40FEBS exposes an executable named `febs` to be used within the scripts of your `package.json`, e.g:
41
42 "scripts": {
43 "build": "febs prod",
44 "dev": "febs dev --no-dev-server",
45 "live-reload": "febs dev"
46 "watch": "febs dev --no-dev-server --watch"
47 }
48
49#### Update or use [defaults](#default-configuration) to specify paths for the CSS and JS you want to compile and [run](#run)
50
51See [Command-line Interface](#command-line-interface) for more details and additional ways to run.
52
53## Default Configuration
54
55### Entry points
56 - Default JavaScript entry point: `/src/js/entry.js`
57 - Default Style entry point: `/src/style/entry.less`
58
59### Output path
60 - Bundles written to: `/dist/<packageName>/`.
61
62Given the above defaults, FEBS will generate two bundles at the following paths:
63
64 ./dist/<packageName>/app.1234.js
65 ./dist/<packageName>/app.1234.css
66
67You can adjust these default configurations using the [febs configuration](#febs-configuration)
68
69## Build Features
70
71### JavaScript
72 - Supports [Vue](https://vuejs.org/) [single file components](https://vuejs.org/v2/guide/single-file-components.html).
73 - Transpiles latest JavaScript via [@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env)
74 - Automatically polyfills based on usage and [targeted browsers](https://github.com/rei/febs/blob/babel-polyfills/webpack-config/webpack.base.conf.js#L96).
75
76### Style
77 - [Less](http://lesscss.org/) - [deprecated](#deprecation)
78 - [Sass/SCSS](https://sass-lang.com/)
79 - [PostCSS](https://github.com/postcss)
80
81### Source Maps
82Source maps are generated for your bundles via the following [`webpack` methods](https://webpack.js.org/configuration/devtool/):
83
84* dev: `eval-source-map`
85* prod: `source-map`
86
87### Linting
88As FEBS is responsible only for *building* your code, it does not provide for linting. You should
89implement a linting step per your style guide as a separate npm task in your `package.json`.
90
91### Code watching
92To enable code watching, run:
93
94 febs dev --no-dev-server --watch
95
96### Live reloading
97@TODO: additional detail
98
99## FEBS Core
100
101### Command-line interface
102FEBS provides a simple command-line interface.
103
104### Production and Development Builds
105
106#### Production Build Task
107
108 febs prod
109
110#### Development Build Task
111
112 febs dev
113 febs dev -no-dev-server
114 febs dev --no-dev-server --watch
115
116### FEBS Configuration
117
118If the default entry/output paths don't work for you, you can specify them by using a `febs-config.json` file next to your package.json that is using `febs`.
119
120Here is an example of `entry`/`output` paths using a typical `Java`/`Maven`-like project directory structure.
121
122*`febs-config.json`*
123
124 {
125 "entry": {
126 "details": [
127 "src/main/js/pages/details/entry.js"
128 ],
129 "details-reviews": [
130 "src/main/js/pages/details/reviews.js"
131 "src/main/js/pages/details/write-review.js"
132 ]
133 }
134 "output": {
135 "path": "./target/classes/dist"
136 }
137 }
138
139Notes:
140 - the `febs-config.json` overrides the `webpack.overrides.config.js` file. (i.e., if `entry` and `output` are specified in both, the build will use the entries in `febs-config.json`.
141 - the `entry/output` paths are resolved relative to npm root.
142 - the `output` path is appended with `<package name>`, i.e., `dist/details/`. Use the overrides file if you want to specify a unique path.
143
144#### `entry` property
145
146In the `febs-config.json` example above, we are creating our own entry points instead of using the
147[defaults](#default-configuration). We specify the path where our JavaScript and styles live.
148
149Note: The `entry` paths are specified relative to npm root directory.
150
151#### `output` property
152
153In the `febs-config.json` example above we change the default output path to the Java classpath where a Java asset injector will be able to read for injection.
154
155Notes:
156- The `output` paths are specified relative to npm root directory.
157- the `output` path is appended with `<package name>`, i.e., `dist/<package name>/`. Use the overrides file if you want to specify a unique path.
158
159#### Example configuration output
160Given the above example, FEBS will generate two bundles at the following paths:
161
162 ./target/classes/dist/<package name>/details.1234.js
163 ./target/classes/dist/<package name>/detail-reviews.1234.js
164
165- `details.1234.js` will only contain JavaScript contained in entry.js (including its dependencies)
166
167- `details-reviews.1234.js` will bundle reviews.js and write-review.js files into one bundle
168
169If you'd like to further configure FEBS, you can look at the [webpack overrides](#webpack-overrides)
170
171### Webpack overrides
172
173You may also configure additional loaders and update your `input/output` entries in a local file
174called `webpack.overrides.conf.js` (See below example).
175
176If you do need an override, consider opening a PR to get this pulled into the
177base config or reach out to [support](#support). By doing so, we can all benefit from your overrides and prevent others from needing to duplicate the same overrides.
178
179 // Webpack.overrides.conf.js
180 module.exports = {
181 .
182 .
183 module: {
184 rules: [{
185 test: '/\.js$/'
186 use: {
187 loader: 'cool-js-loader'
188 }
189 }]
190 },
191 .
192 .
193 plugins: [
194 new CoolPlugin()
195 ]
196 };
197
198You can find out all of the Webpack defaults by reviewing the [base webpack config](https://github.com/rei/front-end-build-configs/blob/master/application/microsite/webpack.base.conf.js).
199
200## Additional Concepts
201
202### Build Manifest
203
204A `febs-manifest.json` is built to the output directory. This is a
205mechanism to be used by an asset injector to insert assets onto a page.
206
207@TODO: Additional detail
208
209### Asset Injector
210
211An asset injector uses a [febs-manifest.json](#build-manifest) to insert production
212assets into the markup of a webpage.
213
214See our example JavaScript implementation of the an asset injector. One could
215create one to be used by Thymeleaf, Freemarker, JSP Tags, Vue, React, Mustache, Handlebars, etc.
216
217@TODO: publish JavaScript implementation and asset pipeline architectural
218diagrams and relate to an "asset pipeline".
219
220## Project Information
221
222### Release management
223
224The project strictly use [semver](https://semver.org/).
225
226The main thing to call out here is that if maintainers (intentionally) introduce
227an incompatible Webpack configuration change, the major version is bumped. When
228the project moves from Webpack 3 to 4, the major version is bumped.
229
230If the project unintentionally introduces a new bug through a change through
231febs core or build features, there will be a prompt fix. Additionally, maintainers
232will continue to improve our unit and functional testing strategies and bug
233response times.
234
235Somewhat related, the intention is to move the Webpack configuration to a separate
236repository and have that be configurable. At that point the project can have more
237fine-grained release management and flexibility as well as allow non-internal
238customers to have complete control over their shared base configuration.
239
240### Deprecation
241
242When something gets deprecated, it will not be supported in the next major
243release but will continue to get [supported](#support) for the previous version.
244
245### Support
246
247The project focus is around FEBS core. For [Build Features](#build-features)
248it should be look at as community of practice effort, this is one of the main ideas.
249However, a maintainer should be a major contributor to features.
250
251*For our internal customers:* Think of FEBS as just a base Webpack
252config that you can edit that happens to be in a different repository
253
254Maintainers support one major version behind and attempt to minimize and group
255up major version releases to reduce upgrade/support burden.
256
257#### Internal open source customers
258
259We fully support our internal customers. That means we will respond to Slack
260messages and help troubleshoot issues, feature requests, etc.
261
262Feel free to swing by or hit us up on Slack in the #febs-users channel or just file
263an issue here :)
264
265#### External open source customers
266
267Maintainers will respond to Github issues within a week for issues with FEBS core.
268Unfortunately, there are no guarantees for "immediate" support due to bandwidth.
269However, we are happy to collaborate and work together on pull requests. You are
270very much welcome and encouraged to fork this project and see where it goes.
271
272Also, we'd love to hear your ideas and feedback on different approaches or similar
273solutions in the community that you think could improve FEBS.