npm 7 changed how it resolves dependencies, and starter-kit fails to
build with lots of unresolved peer dependencies of PatternFly.
With an absolute path, `resolve.modules` will only look in that
directory; the default is a relative path "node_modules" that just
works [1]. Use that default, as we don't use `$SRCDIR` in this project
anyway.
[1] https://webpack.js.org/configuration/resolve/#resolvemodules
CentOS/RHEL 9 switched to OpenSSL 3, which does not support the `md4`
hash any more. webpack 5 hardcodes that in no less than 21 places, so
monkey-patch `crypto.createHash()` to substitute sha256 for md4.
Hack to work around https://github.com/webpack/webpack/issues/13572
Bring back terser-webpack-plugin from commit c52136c051 and re-enable
it. It builds the autogenerated dist/index.js.LICENSE.txt which is quite
important for shipping distribution packages -- c-{podman,machines} both
do this.
Backport 95021c336e
to make sure that the webpack for the release tarball is *actually*
built in production mode.
We don't need to explicitly mention TerserJSPlugin any more (from commit
6b8611), as webpack 5 can now extend the `minimizer:` list with the
special `...` syntax.
This gets rid of several `npm install` warnings:
deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
as well as 10 MB of node_modules.
Fixes these `npm install` warnings:
> deprecated [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
> deprecated [email protected]: This loader has been deprecated. Please use eslint-webpack-plugin
This works better with the current eslint loader, as then eslint and
babel can look at the same configuration. See
<https://babeljs.io/docs/en/config-files>.
This is similar to .eslintrc.json.
Convert the `po2json` script into a webpack plugin, and integrate the
(now trivial) po.empty.js template.
This is the last step for building the entire dist/ directory with
`npm run build` (i.e. a tool that web developers are familiar with),
and not having a split webpack+make toolchain any more.
Otherwise there is just too much noise and when something is broken, the
error is above 3 pages of pointless logs.
See https://webpack.js.org/configuration/stats/
Cherry-picked from cockpit-podman commit 5989b20a05a.
If so, show the versions, which may be useful for comparing builds. If
not, show an useful error message. Previously, you were left with ~ 80
identical unintelligible error messages and leftover temporary
directories.
Closes#404Fixes#391
As `files` is now the only entry in `info`, rename it to a `copy_files`
constant, and drop `info` completely.
Drop the "qualify" loop and add the src/ subdirectory to the path
directly. This is more explicit, thus easier to understand, and simpler.
Drop the now unused "vpath" function.
Drop the "qualify" loop and add the src/ subdirectory to the path
directly. This is more explicit, thus easier to understand, and simpler.
Also move it into the `modules` declaration directly, so that (1) it's
easier to see what it actually means, and (2) info.files is for a
completely different purpose.
This is simple enough to be inline, and it's also not meant to be
expanded: `cockpit` is the only legit external symbol, everything else
ought to be bundled.
The default of `path` and `sourceMapFilename` are already what we want,
no need to set them explicitly.
The `output.filename` is already `[name].js`, and it's totally not
important to name the file differently in production mode (it will then
just be `index.js.gz`, compared to index.js in development mode).
node-sass is a compiled ELF module, which is problematic for
distributions that want to rebuild everything from source. The sassc CLI
program is packaged everywhere, and both use the same libsass library.
So drop node-sass and sass-loader, and replace it with a simple loader
wrapper around sassc.
This also saves 122 npm packages (16 MB in node_modules/).
Closes#382
compression-webpack-plugin fixes https://www.npmjs.com/advisories/1548
Adjust to new copy-webpack-plugin API.
Thew new modules now create dist/index.html.gz in `NODE_ENV=production`
mode, so switch `WEBPACK_TEST` to index.css instead (which remains
uncompressed in both modes).
This recently started to overflow inotify, and we don't need that --
it's fine to restart webpack when changing package.json, and it happens
rarely enough.
Closes#345
* Stop importing cockpit's base1/patternfly.css
This is deprecated API and will be dropped at some point, in favor
of projects shipping their own CSS.
Install and import the styles from PF4 now.
* Use webpack based string replacement for removing the font-face rules from PF4
Doing the seddery in Makefile breaks `npm run build`, webpack watching,
and is generally brittle.
Do the font replacement hacking with `string-replace-loader`, which fits into webpack much more nicely.
There is still some potential simplification by not duplicating the
entire scss loader chain.
Co-authored-by: Martin Pitt <[email protected]>
Closes#315
It looks like Webpack is deprecating extract-text-webpack-plugin in favor of
mini-css-extract-plugin.
Discussion can be found here: webpack-contrib/extract-text-webpack-plugin#731
Closes#271
eslint is much more powerful and flexible than jshint, and we don't want
to promote writing new projects with pre-ES6 code.
As a side effect, this also avoids downloading PhantomJS (see
https://github.com/jshint/jshint/issues/3318), thereby cutting down
node_modules/ from 470 MB to 210 MB.