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)
|
8 | designed to be used by a community of front-end developers or a series of projects using a similar set of technologies
|
9 | in order to reduce duplicate effort of build configurations.
|
10 |
|
11 | Its 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 |
|
27 | Learn more about [REI's Front-End Build System ](https://engineering.rei.com/frontend/the-rei-front-end-build-system.html)
|
28 | by 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 |
|
40 | FEBS 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 |
|
51 | See [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 |
|
62 | Given 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 |
|
67 | You 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
|
82 | Source 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
|
88 | As FEBS is responsible only for *building* your code, it does not provide for linting. You should
|
89 | implement a linting step per your style guide as a separate npm task in your `package.json`.
|
90 |
|
91 | ### Code watching
|
92 | To 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
|
102 | FEBS 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 |
|
118 | If 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 |
|
120 | Here 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 |
|
139 | Notes:
|
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 |
|
146 | In 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 |
|
149 | Note: The `entry` paths are specified relative to npm root directory.
|
150 |
|
151 | #### `output` property
|
152 |
|
153 | In 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 |
|
155 | Notes:
|
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
|
160 | Given 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 |
|
169 | If you'd like to further configure FEBS, you can look at the [webpack overrides](#webpack-overrides)
|
170 |
|
171 | ### Webpack overrides
|
172 |
|
173 | You may also configure additional loaders and update your `input/output` entries in a local file
|
174 | called `webpack.overrides.conf.js` (See below example).
|
175 |
|
176 | If you do need an override, consider opening a PR to get this pulled into the
|
177 | base 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 |
|
198 | You 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 |
|
204 | A `febs-manifest.json` is built to the output directory. This is a
|
205 | mechanism to be used by an asset injector to insert assets onto a page.
|
206 |
|
207 | @TODO: Additional detail
|
208 |
|
209 | ### Asset Injector
|
210 |
|
211 | An asset injector uses a [febs-manifest.json](#build-manifest) to insert production
|
212 | assets into the markup of a webpage.
|
213 |
|
214 | See our example JavaScript implementation of the an asset injector. One could
|
215 | create one to be used by Thymeleaf, Freemarker, JSP Tags, Vue, React, Mustache, Handlebars, etc.
|
216 |
|
217 | @TODO: publish JavaScript implementation and asset pipeline architectural
|
218 | diagrams and relate to an "asset pipeline".
|
219 |
|
220 | ## Project Information
|
221 |
|
222 | ### Release management
|
223 |
|
224 | The project strictly use [semver](https://semver.org/).
|
225 |
|
226 | The main thing to call out here is that if maintainers (intentionally) introduce
|
227 | an incompatible Webpack configuration change, the major version is bumped. When
|
228 | the project moves from Webpack 3 to 4, the major version is bumped.
|
229 |
|
230 | If the project unintentionally introduces a new bug through a change through
|
231 | febs core or build features, there will be a prompt fix. Additionally, maintainers
|
232 | will continue to improve our unit and functional testing strategies and bug
|
233 | response times.
|
234 |
|
235 | Somewhat related, the intention is to move the Webpack configuration to a separate
|
236 | repository and have that be configurable. At that point the project can have more
|
237 | fine-grained release management and flexibility as well as allow non-internal
|
238 | customers to have complete control over their shared base configuration.
|
239 |
|
240 | ### Deprecation
|
241 |
|
242 | When something gets deprecated, it will not be supported in the next major
|
243 | release but will continue to get [supported](#support) for the previous version.
|
244 |
|
245 | ### Support
|
246 |
|
247 | The project focus is around FEBS core. For [Build Features](#build-features)
|
248 | it should be look at as community of practice effort, this is one of the main ideas.
|
249 | However, a maintainer should be a major contributor to features.
|
250 |
|
251 | *For our internal customers:* Think of FEBS as just a base Webpack
|
252 | config that you can edit that happens to be in a different repository
|
253 |
|
254 | Maintainers support one major version behind and attempt to minimize and group
|
255 | up major version releases to reduce upgrade/support burden.
|
256 |
|
257 | #### Internal open source customers
|
258 |
|
259 | We fully support our internal customers. That means we will respond to Slack
|
260 | messages and help troubleshoot issues, feature requests, etc.
|
261 |
|
262 | Feel free to swing by or hit us up on Slack in the #febs-users channel or just file
|
263 | an issue here :)
|
264 |
|
265 | #### External open source customers
|
266 |
|
267 | Maintainers will respond to Github issues within a week for issues with FEBS core.
|
268 | Unfortunately, there are no guarantees for "immediate" support due to bandwidth.
|
269 | However, we are happy to collaborate and work together on pull requests. You are
|
270 | very much welcome and encouraged to fork this project and see where it goes.
|
271 |
|
272 | Also, we'd love to hear your ideas and feedback on different approaches or similar
|
273 | solutions in the community that you think could improve FEBS.
|