|
10 | 10 | [](https://github.com/semantic-release/semantic-release) |
11 | 11 | [](http://commitizen.github.io/cz-cli/) |
12 | 12 |
|
13 | | -The project uses webpack features like chunking to allow metalsmith |
14 | | -to inject the scripts and styles in the DOM where they actually belong. These |
15 | | -chunks reflect the scripts in the document head, the scripts at the end of the |
16 | | -document body and also a stylesheet file for the css. Thanks to hashed filenames, |
17 | | -we can effectively use browser caching and cache busting. |
| 13 | +## :cloud: Installation |
18 | 14 |
|
19 | | -This is still work in progress. See the checkboxes below to get an overview |
20 | | -about the project status. |
| 15 | +Cloning the repo or downloading a release might be the best idea. |
21 | 16 |
|
22 | | -## Install |
| 17 | +You may build on top of this project or extract parts you need for your own projects. |
| 18 | + |
| 19 | +Afterwars, simply install all dependencies by running: |
23 | 20 |
|
24 | 21 | ```js |
25 | 22 | yarn || npm install |
26 | 23 | ``` |
27 | 24 |
|
28 | | -## Usage |
| 25 | +## :rocket: Technology |
| 26 | + |
| 27 | +This boilerplate tries to combine the best out of [metalsmith](http://www.metalsmith.io/) and [webpack](webpack.js.org). |
| 28 | + |
| 29 | +### Content generation via metalsmithpreviewp |
| 30 | + |
| 31 | +* Simple, pretty much not special metalsmith implementation |
| 32 | +* [metalsmith-assets](https://github.com/treygriffith/metalsmith-assets) to copy webpack files |
| 33 | +* [metalsmith-markdownit](https://github.com/segmentio/metalsmith-markdown) to render markdown |
| 34 | +* [metalsmith-layouts](https://github.com/superwolff/metalsmith-layouts) to apply layouts |
| 35 | + |
| 36 | + |
| 37 | +### Scripts and stylesheets via webpack |
| 38 | + |
| 39 | +* Full power of webpack including tree shaking and minimize |
| 40 | +* Uses webpack-dev-server (actually [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware)) under the hood for dev |
| 41 | +* Styles get included via require within `page.js` and extracted to a css file via [ExtractTextPlugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) |
| 42 | + |
| 43 | +## :bookmark_tabs: Project File Structure |
| 44 | +|Pattern|Description| |
| 45 | +|-|-| |
| 46 | +|`./content/*` | website content files, mainly markdown files| |
| 47 | +|`./layouts/*.html` | [metalsmith-layouts](https://github.com/superwolff/metalsmith-layouts) layout files| |
| 48 | +|`./src/config/paths.js` | path configuration |
| 49 | +|`./src/assets/css,js` | page javascript and stylesheet files| |
| 50 | +|`./src/scripts/*.js` | build process & dev environment scripts| |
| 51 | +|`./dist/assets/**/*` | webpack output directory| |
| 52 | +|`./dist/site/**/*` | metalsmith output directory| |
| 53 | + |
| 54 | +## :hammer_and_wrench: Development and tooling |
| 55 | + |
| 56 | +You can start a fully featured development server via `yarn dev` (or `npm run dev`). |
| 57 | + |
| 58 | +It will spawn a html server at `http://localhost:3000` including browser-sync for live reload. |
| 59 | + |
| 60 | +### :recycle: Live reload details |
| 61 | + |
| 62 | +Browser sync spawns a basic webserver with the webpack-dev-middleware injected. |
| 63 | + |
| 64 | +The live reload gets very effective by combining 3 different reload techniques: |
| 65 | + |
| 66 | +* [browser-sync](https://browsersync.io/): Rebuilds metalsmith when content or layouts change. |
| 67 | +* [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware): Triggers browser-sync when webpack files like scripts or styles change |
| 68 | +* [nodemon](https://github.com/remy/nodemon): Restarts dev server when build scripts or config changes |
| 69 | + |
| 70 | +### :bulb: Tipps & tricks |
29 | 71 |
|
30 | | -Check `npm run` for an overview of all available scripts. |
| 72 | +1. The dev server supports the `rs` shortcut while running. Simply type and hit enter to restart the server manually |
| 73 | +2. The `metalsmith-helpers.js` in the scripts folder exports two metalsmith debugging plugins: A `StatisticsPlugin` for a general overview and a `DebugPlugin` for in-deepth insights |
| 74 | +3. The metalsmith-layouts config contains a little helper for handlebars to output variable content. Usage: `<pre>{{debug YOUR_VARIABLE}}</pre>` (Hint: use `this` as variable to debug display the whole file metadata) |
| 75 | +4. Check `npm run` for an overview of all available scripts. |
31 | 76 |
|
32 | | -### `npm run build` |
| 77 | +## :gear: Build process |
33 | 78 |
|
34 | | -- [x] Build webpack and store assets to disk |
35 | | -- [x] Build metalsmith, take webpack assets and combine to static site |
36 | | -- [ ] Discover a way to use metalsmith-cached when building via circleci |
| 79 | +You can run a fresh page build via `yarn build` (Or `npm run build`) |
37 | 80 |
|
38 | | -### `npm run dev` |
| 81 | +1. `npm-scripts`: Set `DEBUG` environment variable to `metalsmith*` to enable metalsmith debugging |
| 82 | +2. `npm-scripts`: Clean up `./dist/*` directories |
| 83 | +3. `webpack`: Build javascript and stylesheet files via webpack |
| 84 | +4. `metalsmith`: Copy webpack assets to site directory |
| 85 | +5. `metalsmith`: Fingerprint webpack assets |
| 86 | +6. `metalsmith`: Compile markdown files |
| 87 | +7. `metalsmith`: Apply layouts |
| 88 | +8. `metalsmith`: Show statistics |
39 | 89 |
|
40 | | -Starts development server at http://localhost:3000 |
| 90 | +Et voilà. You can find your generated website in `./dist/site/`. See below how you can preview and deploy the result. |
41 | 91 |
|
42 | | -- [x] Run basic express server to expose the actual static site |
43 | | -- [x] Implement webpack via webpack-dev-middleware |
44 | | -- [x] Use metalsmith-watch to watch and publish metalsmith changes |
45 | | -- [x] Use fs.watch to load new webpack bundle names into metalsmith |
46 | | -- [ ] Enable hot module reloading with webpack-dev-middleware |
| 92 | +## :ship: Deployment & production server |
47 | 93 |
|
48 | | -### `npm run server` |
| 94 | +With `yarn deploy` (or `npm run deploy`) you can deploy your latest website directly to GitHub pages via [gh-pages](https://www.npmjs.com/package/gh-pages) |
49 | 95 |
|
50 | | -- [x] Run basic express server to expose the last build static site |
| 96 | +Running `yarn server` (or `npm run server`) will spawn a simple production server which is great for testing the final version. |
51 | 97 |
|
52 | | -## Contributing |
| 98 | +## :sparkling_heart: Contributing |
53 | 99 |
|
54 | 100 | This project follows the [standard](https://github.com/feross/standard) coding and the [conventional changelog](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md) commit message style. Also it is configured to never decrease the code coverage of its tests. |
55 | 101 |
|
56 | 102 |
|
57 | | -Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/axe312ger/metalsmith-sharp/issues/new). |
| 103 | +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/axe312ger/metalsmith-webpack-suite/issues/new). |
58 | 104 | But before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines. |
0 commit comments