Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation in printable format (CSS media queries) #2754

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
92426f5
CSS rules added for printing, script added to create chapter-wide doc…
SetTrend Dec 14, 2018
c42345a
Merge branch 'master' into printable-doc
SetTrend Jan 8, 2019
2cf4fca
_all.md files removed, .gitigore amened to exclude _all.md files from…
SetTrend Jan 13, 2019
496d442
Merge branch 'printable-doc' of https://github.com/SetTrend/webpack.j…
SetTrend Jan 13, 2019
49901a1
CSS rules added for printing, script added to create chapter-wide doc…
SetTrend Dec 14, 2018
c1e40be
_all.md files removed, .gitigore amened to exclude _all.md files from…
SetTrend Jan 13, 2019
df53ddd
Merge branch 'printable-doc' of https://github.com/SetTrend/webpack.j…
SetTrend Jan 13, 2019
df10358
docs(plugins) IgnorePlugin new syntax and options (#2721)
EugeneHlushko Dec 16, 2018
8793381
docs(plugins): Add title to cacheGroups (#2227)
sharh Dec 16, 2018
cf26894
Update split-chunks-plugin.md
montogeek Dec 16, 2018
5b45f87
Update split-chunks-plugin.md
montogeek Dec 16, 2018
d74520b
Revert "cacheGroups" (#2725)
EugeneHlushko Dec 18, 2018
96792a0
docs(config) document optimization.chunkIds (#2727)
EugeneHlushko Dec 20, 2018
5c5981d
CSS rules added for printing, script added to create chapter-wide doc…
SetTrend Dec 14, 2018
6603ced
_all.md files removed, .gitigore amened to exclude _all.md files from…
SetTrend Jan 13, 2019
d696a31
Merge branch 'master' into printable-doc
SetTrend Jan 23, 2019
2a90c76
Configuration for summarized help files removed from `package.json`.
SetTrend Jan 23, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ starter-kits-data.json
.DS_Store
yarn-error.log
package-lock.json
src/content/**/*_all.md
78 changes: 78 additions & 0 deletions concatenate-docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// start message
console.info("\x1b[0m\x1b[36mConcatenating help files of each directory to create chapter-wide help files to be used for printing help ...\x1b[0m");

// ------ various includes ------
const fs = require("fs");
const path = require("path");
const os = require("os");
const front = require("front-matter");

// root path
const rootPath = path.join("src", "content");

/* getDirectoryRecursive() recursively walks through
all sub directories of the provided root path,
concatenates the MarkDown files' content in
each directory, sorted by their FrontMatter sort
attribute, and creates a compound MarkDown file
named by using the directory name, prefixed by an
underscore and suffixed by "_all.md" from the
concatenated content in the corresponding directory.
*/
(function getDirectoryRecursive(basePath)
{
// log current working directory
console.log("\x1b[0m\x1b[32m " + basePath + "\x1b[0m");

// create destination file name of compound file
const targetFilePath = path.join(basePath, `${basePath.substr(rootPath.length).replace(/[/\\]/, "_")}_all.md`);

if (fs.existsSync(targetFilePath)) fs.unlinkSync(targetFilePath); // delete target file if it already exists

fs.readdir(basePath, function (err, fileNames) // list current working directory
{
if (err) throw err;

let fileContents = [];

for (let file of fileNames) // for each directory entry ...
{
const fullPath = path.join(basePath, file);

if (fs.statSync(fullPath).isDirectory()) getDirectoryRecursive(fullPath); // if the directory entry is a directory, recurse into that directory
else if (fullPath.endsWith(".md")) // if the directory entry is a MarkDown file, add it to the list of files to be processed
{
let fc = fileContents[fileContents.length] = front(fs.readFileSync(fullPath).toString());

if (!fc.attributes.sort) --fileContents.length; // only include files providing a FrontMatter "sort" attribute
}
}

// sort MarkDown files by FrontMatter "sort" attribute (QuickSort)
for (let i = 0;i < fileContents.length - 1;++i)
for (let j = i + 1;j < fileContents.length;++j)
{
const left = fileContents[i].attributes, right = fileContents[j].attributes;

if (left.sort > right.sort
|| left.sort == right.sort && left.title > right.title)
[fileContents[i], fileContents[j]] = [fileContents[j], fileContents[i]];
}

// write compound target file
const targetFile = fs.createWriteStream(targetFilePath);

targetFile.on("error", (error) => { throw error; });

for (let file of fileContents)
{
targetFile.write(os.EOL + os.EOL + "# " + file.attributes.title + os.EOL); // use FrontMatter "title" attribute as main heading of target file
targetFile.write(file.body);
}

targetFile.end();
});
})(rootPath);

// end message
process.on("exit", () => { console.info("\x1b[0m\x1b[36mSuccessfully created \"_all.md\" help files in each directory within \"" + rootPath + "\".\x1b[0m"); });
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
"init:generated": "mkdirp ./generated/loaders && mkdirp ./generated/plugins ",
"lint": "run-s lint:*",
"lint:js": "eslint . --ext .js,.jsx,.md",
"lint:markdown": "markdownlint --rules markdownlint-rule-emphasis-style --config ./.markdownlint.json *.md ./src/content/*.md ./src/content/**/*.md",
"lint:markdown": "markdownlint --rules markdownlint-rule-emphasis-style --config ./.markdownlint.json --ignore *.md ./src/content/**/*.md",
"lint:social": "alex . -q",
"lint:prose": "cp .proselintrc ~/ && proselint src/content",
"test": "npm run lint",
"sitemap": "cd build && sitemap-static --prefix=https://webpack.js.org/ > sitemap.xml"
"sitemap": "cd build && sitemap-static --prefix=https://webpack.js.org/ > sitemap.xml",
"chapterize": "node ./concatenate-docs.js"
},
"husky": {
"hooks": {
Expand Down
4 changes: 4 additions & 0 deletions src/components/Footer/Footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
.footer {
width: 100%;
flex: 0 0 auto;

@media print {
display: none !important;
}
}

.footer__inner {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Page/Page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const Page = ({ page, section }) => {
)}

{ contributors.length > 0 && (
<div>
<div className="contributors__section">
<hr />
<h3>Contributors</h3>
<Contributors contributors={ contributors } />
Expand Down
7 changes: 7 additions & 0 deletions src/components/Page/Page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@
padding: 1.5em;
}
}

.contributors__section, .interactive
{
@media print {
display: none !important;
}
}
4 changes: 4 additions & 0 deletions src/components/PageLinks/PageLinks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
@import 'functions';

.page-links {
@media print {
display: none !important;
}

position: absolute;
display: none;
top: 1.5em;
Expand Down
30 changes: 30 additions & 0 deletions src/content/configuration/optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,36 @@ module.exports = {
};
```

## `optimization.chunkIds`

`bool: false` `string: natural, named, size, total-size`

Tells webpack which algorithm to use when choosing chunk ids. Setting `optimization.chunkIds` to `false` tells webpack that none of built-in algorithms should be used, as custom one can be provided via plugin. There are couple of defaults for `optimization.chunkIds`:

- if [`optimization.occurrenceOrder`](#optimization-occurrenceorder) is enabled `optimization.chunkIds` is set to `'total-size'`
- Disregarding previous if, if [`optimization.namedChunks`](#optimization-namedchunks) is enabled `optimization.chunkIds` is set to `'named'`
- if none of the above, `optimization.namedChunks` will be defaulted to `'natural'`

The following string values are supported:

Option | Description
----------------------- | -----------------------
`'natural'` | Numeric ids in order of usage.
`'named'` | Readable ids for better debugging.
`'size'` | Numeric ids focused on minimal initial download size.
`'total-size'` | numeric ids focused on minimal total download size.

__webpack.config.js__

```js
module.exports = {
//...
optimization: {
chunkIds: 'named'
}
};
```

## `optimization.nodeEnv`

`string` `bool: false`
Expand Down
2 changes: 1 addition & 1 deletion src/content/plugins/ignore-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ new webpack.IgnorePlugin({

## Example of ignoring Moment Locales

As of [moment](https://momentjs.com/) 2.18, all locales are bundled together with the core library (see [this GitHub issue](https://github.com/moment/moment/issues/2373)).
As of [moment](https://momentjs.com/) 2.18, all locales are bundled together with the core library (see [this GitHub issue](https://github.com/moment/moment/issues/2373)).

The `resourceRegExp` parameter passed to `IgnorePlugin` is not tested against the resolved file names or absolute module names being imported or required, but rather against the _string_ passed to `require` or `import` _within the source code where the import is taking place_. For example, if you're trying to exclude `node_modules/moment/locale/*.js`, this won't work:

Expand Down