|
| 1 | +_just: title: Configurating |
| 2 | +# `just.config.js` |
| 3 | +`just.config.js` is a configuration file for the $${name}$$. This is JavaScript file that should export the configuration as Object that will be parsed to a JSON file by $${name}$$. When running, $${name}$$ always tries to resolve the config file named `just.config.js` in the repository root. |
| 4 | +The most basic configuration file would look like this: |
| 5 | +```js |
| 6 | +module.exports = { |
| 7 | + // ... |
| 8 | +} |
| 9 | +``` |
| 10 | +-# Note that $${name}$$ does not support `export default`. |
| 11 | +> [!NOTE] You don't need a `package.json` file or its `type` option. |
| 12 | +
|
| 13 | +## Preprocessing |
| 14 | +$${name}$$ supports preprocessing by compilers: |
| 15 | +- TypeScript compiler |
| 16 | +- Dart Sass |
| 17 | + |
| 18 | +> [!WARNING] Third-party compilers may not be as fast, so they can slow down the process significantly. |
| 19 | +
|
| 20 | +To use any of these compilers, add `compile`: |
| 21 | +-# `just.config.js` |
| 22 | +```js |
| 23 | +module.exports = { |
| 24 | + // ... |
| 25 | + compile: { |
| 26 | + // ... ( extension : true ) |
| 27 | + } |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +<details> |
| 32 | + <summary>Example</summary> |
| 33 | +-# `just.config.js` |
| 34 | +```js |
| 35 | +module.exports = { |
| 36 | + // ... |
| 37 | + compile: { |
| 38 | + ts: true, // TypeScript compiler |
| 39 | + sass: true, // Dart Sass |
| 40 | + scss: true // Dart Sass |
| 41 | + } |
| 42 | +} |
| 43 | +``` |
| 44 | +</details><br> |
| 45 | + |
| 46 | +> [!IMPORTANT] But then, before running $${name}$$, make sure you have installed the compilers that you are going to use. You can also install those compilers through $${name}$$ when running it: |
| 47 | +
|
| 48 | +### Installing third-party dependencies |
| 49 | +To install any of the supported compilers listed above, add `install`: |
| 50 | +-# `just.config.js` |
| 51 | +```js |
| 52 | +module.exports = { |
| 53 | + // ... |
| 54 | + install: { |
| 55 | + // ... ( lowercased name with spaces replaced with underscores : true ) |
| 56 | + } |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +<details> |
| 61 | + <summary>Example</summary> |
| 62 | +-# `just.config.js` |
| 63 | +```js |
| 64 | +module.exports = { |
| 65 | + // ... |
| 66 | + install: { |
| 67 | + typescript_compiler: true, |
| 68 | + dart_sass: true |
| 69 | + } |
| 70 | +} |
| 71 | +``` |
| 72 | +</details><br> |
| 73 | + |
| 74 | +-# The positions of `compile` and `install` in the config file do not matter. |
| 75 | + |
| 76 | +## Postprocessing |
| 77 | +$${name}$$ provides some postprocessing options: |
| 78 | +- Sitemap generator |
| 79 | +- Inserter |
| 80 | + |
| 81 | +These are included in $${name}$$ and are not third-parties nor need to be installed separately from $${name}$$. |
| 82 | + |
| 83 | +### Sitemap generator |
| 84 | +It generates a `sitemap.xml` file. |
| 85 | +-# `just.config.js` |
| 86 | +```js |
| 87 | +module.exports = { |
| 88 | + // ... |
| 89 | + sitemap: { |
| 90 | + generateSitemap: true, |
| 91 | + protocol: 'https:', // or 'http:'. Required. |
| 92 | + // ... |
| 93 | + } |
| 94 | +} |
| 95 | +``` |
| 96 | +You can specify input and output directories, as well as modify output URLs: |
| 97 | +-# `just.config.js` |
| 98 | +```js |
| 99 | +module.exports = { |
| 100 | + // ... |
| 101 | + sitemap: { |
| 102 | + // ... |
| 103 | + base: 'path/to/website', // Input dir. GitHub Action path input from your workflow file or '.' by default. |
| 104 | + output: 'path/to/website/output', // Output dir. Input dir by default. |
| 105 | + path: 'example/path/', // Modifies output URLs. This example will add "example/path" to the output URLs right after the host name ("https://example.com/example/path/file.html"). GitHub Action fix-path input from your workflow file by default. |
| 106 | + unpath: 'example_prefix' // Modifies output URLs. This example will remove "example_prefix" from the file path ("https://example.com/example_prefix_file.html" -> "https://example.com/_file.html"). |
| 107 | + } |
| 108 | +} |
| 109 | +``` |
| 110 | +You can also specify pages that should not be included in the sitemap: |
| 111 | +-# `just.config.js` |
| 112 | +```js |
| 113 | +module.exports = { |
| 114 | + // ... |
| 115 | + sitemap: { |
| 116 | + // ... |
| 117 | + hidePages: [ |
| 118 | + '/path/to/page' // The path to a page should start with a slash and should not end with an extension name. |
| 119 | + ] |
| 120 | + } |
| 121 | +} |
| 122 | +``` |
| 123 | + |
| 124 | +### Inserter |
| 125 | +Currently, it allows you to insert anything you want into the `<head>` of every HTML page: |
| 126 | +-# `just.config.js` |
| 127 | +```js |
| 128 | +module.exports = { |
| 129 | + // ... |
| 130 | + insert: { |
| 131 | + htmlHead: '<!-- This will be inserted into the head tag of every HTML page /-->' |
| 132 | + } |
| 133 | +} |
| 134 | +``` |
| 135 | + |
| 136 | +_just: prev: /docs/getting-started |
0 commit comments