Commit graph

40 commits

Author SHA1 Message Date
Martin Pitt
0abeda3528 webpack: Use default resolve path for npm 7 compatibility
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
2021-10-12 08:40:12 +02:00
Martin Pitt
3220617fec webpack: Avoid md4 hash for OpenSSL 3 compatibility
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
2021-09-21 10:00:26 +02:00
Martin Pitt
a509dde986 Update terser-webpack-plugin
Following our other projects.
2021-07-27 09:42:10 +02:00
Martin Pitt
28466f7217 webpack: Move from sassc to Dart sass
Fixes #475
2021-07-27 09:42:10 +02:00
Martin Pitt
2624dbb891 Build and ship LICENSE file
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.
2021-04-12 08:45:52 +02:00
Martin Pitt
c52136c051 Move to webpack 5
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.
2021-04-09 13:01:05 +02:00
Martin Pitt
0e608d562a Use current babel/eslint integration
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
2021-04-09 09:46:56 +02:00
Martin Pitt
e449e94564 Move babel config into separate file
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.
2021-04-09 09:46:56 +02:00
Martin Pitt
7f6ef51c12
Build translations with webpack
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.
2021-01-05 14:52:59 +01:00
Martin Pitt
539f293b7e webpack: Fix PatternFly font path
Copy the rule that cockpit and cockpit-podman use. Also change the
quoting, to avoid pointless diff noise. Now they are perfectly in sync.
2020-12-17 17:40:47 +01:00
Martin Pitt
dff4b66671 webpack: Only show errors and warnings
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.
2020-12-17 17:40:47 +01:00
Martin Pitt
6b8611caab Minimize CSS in production builds
Use optimize-css-assets-webpack-plugin for that. terser-webpack-plugin
was already being used by default, but explicitly import it as our
webpack config now references it directly.

https://webpack.js.org/plugins/mini-css-extract-plugin/#minimizing-for-production

Ported from cockpit-podman commit 3caf54fbfe2.
2020-12-17 17:40:47 +01:00
Martin Pitt
8821db1daf
webpack: Check if sassc is installed
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 #404
Fixes #391
2020-12-16 17:47:20 +01:00
Martin Pitt
7fca9b9a26 webpack: Compress css in production mode
Adjust the WEBPACK_TEST file, as index.css is now not reliable (in
production mode it's .css.gz).

Closes #395
2020-11-26 11:17:04 +01:00
Martin Pitt
61db732b4a webpack: Drop compression plugin's minRatio option
The default of 0.8 is just fine, no need to tweak this.
2020-11-26 11:17:04 +01:00
Martin Pitt
8874e6a233 webpack: Declare constants as such 2020-11-26 11:17:04 +01:00
Martin Pitt
9fd1cf7f3f webpack: Simplify copied files
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.
2020-11-26 11:17:04 +01:00
Martin Pitt
230c338a5a webpack: Simplify module.entries
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.
2020-11-26 11:17:04 +01:00
Martin Pitt
8aad356edb webpack: Simplify externals declaration
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.
2020-11-26 11:17:04 +01:00
Martin Pitt
8ea62cb4d7 webpack: Drop unnecessary output settings
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).
2020-11-26 11:17:04 +01:00
Martin Pitt
233b5cfe04 Use sassc instead of node-sass
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
2020-10-28 14:49:52 +01:00
Martin Pitt
a5ade152a8 npm: Upgrade webpack related development dependencies
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).
2020-09-28 07:49:01 +02:00
Martin Pitt
49a721354c
Exclude node_modules from webpack watching
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
2020-07-23 18:04:54 +02:00
Martin Pitt
f2a11ba1de
npm: Bump development dependencies
Closes #334
2020-06-29 22:16:55 +02:00
Katerina Koukiou
96514e279e
main: Stop importing patternfly.css
* 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
2020-05-28 10:01:31 +02:00
Matej Marusak
23e8eb1591 Replace 'extract-text-webpack-plugin' with 'mini-css-extract-plugin'
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
2020-01-27 21:16:30 +01:00
Martin Pitt
1fc1923021 Rename *.es6 to *.js
*.es6 isn't standard naming, that was just an old cockpit-ism. All files
are treated as ES6.
2019-07-17 17:43:01 +02:00
Martin Pitt
eea86c986f Explicitly specify browser compatibility in babel
We do this in cockpit and cockpit-ostree.
2019-07-17 17:43:01 +02:00
Martin Pitt
8a73531374 Use full React instead of react-lite
This is the direction we are going in Cockpit, as react-lite falls
behind with API development and debuggability.

Closes #43
2018-08-29 00:40:16 +02:00
Martin Pitt
842a380766 Move to webpack 4
This has uglification built in.

Closes #42
2018-08-29 00:37:18 +02:00
Martin Pitt
3922333029 Use eslint for everything
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.
2018-08-28 22:57:52 +02:00
Lars Karlitski
7260f5c01f Add scss example
Closes #26
2018-06-22 11:15:57 +02:00
Lars Karlitski
ce7a2d3870 Remove the index.js indirection
Make index.es6 the main entry point.
2017-10-18 16:42:54 +02:00
Lars Karlitski
dd765787e8 Remove all remaining mentions of "subscriptions" 2017-10-18 16:42:54 +02:00
Dominik Perpeet
26a7c0154c Compress distributed files 2017-07-26 10:33:14 +02:00
Dominik Perpeet
23f2f16715 Automatically minify js files for distribution 2017-07-26 10:33:14 +02:00
Dominik Perpeet
a01820e565 Add more sample content to subscriptions page 2017-07-26 10:33:14 +02:00
Dominik Perpeet
2f49b57064 Add sample page 2017-06-20 07:41:52 -04:00
Dominik Perpeet
3f7ac60374 build: Update webpack config
Make building more convenient, add linting and distribute html files.
2017-06-20 07:41:52 -04:00
Sean Toner
811e3eebe0 initial commit. Created a basic webpack.config.js file, some basic .babelrc settings, and some notes on the build 2017-06-20 07:41:52 -04:00