Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit e60c737

Browse files
authored
Merge pull request #1274 from bjones1/webpack_fix
Webpack fix
2 parents 13a6c11 + ceb9393 commit e60c737

4 files changed

Lines changed: 19 additions & 20 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Python package
55

66
on:
77
push:
8-
branches: [master, bookserver]
8+
branches: [master, peer_support]
99
pull_request:
10-
branches: [master, bookserver]
10+
branches: [master, peer_support]
1111

1212
jobs:
1313
build:

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
"author": "",
1919
"license": "ISC",
2020
"devDependencies": {
21-
"copy-webpack-plugin": "^8.0.0",
22-
"compression-webpack-plugin": "^6.0.0",
23-
"css-loader": "^5.0.0",
21+
"copy-webpack-plugin": "^9.0.0",
22+
"compression-webpack-plugin": "^9.0.0",
23+
"css-loader": "^6.0.0",
2424
"css-minimizer-webpack-plugin": "^3.0.0",
25-
"eslint": "^7.0.0",
26-
"html-loader": "^2.0.0",
25+
"html-loader": "^3.0.0",
2726
"html-webpack-plugin": "^5.0.0",
28-
"mini-css-extract-plugin": "^1.0.0",
29-
"style-loader": "^2.0.0",
27+
"mini-css-extract-plugin": "^2.0.0",
3028
"webpack": "^5.61.0",
3129
"webpack-bundle-analyzer": "^4.0.0",
3230
"webpack-cli": "^4.0.0"

runestone/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ def build(all, wd):
150150
else:
151151
os.chdir(findProjectRoot())
152152
sys.path.insert(0, os.getcwd())
153-
if not pathlib.Path(resource_filename("runestone", "dist/runestone.bundle.js")).exists():
154-
click.echo("Error -- You are missing runestone.bundle.js. Please make sure")
153+
if not pathlib.Path(resource_filename("runestone", "dist/webpack_static_imports.json")).exists():
154+
click.echo("Error -- you are missing webpack_static_imports.json. Please make sure")
155155
click.echo("you have Runestone installed correctly.")
156156
click.echo("In a development environment, execute npm run build.")
157157
sys.exit(-1)

webpack.config.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
const path = require("path");
1010

11-
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
1211
const CopyPlugin = require("copy-webpack-plugin");
1312
const CompressionPlugin = require("compression-webpack-plugin");
13+
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
1414
const HtmlWebpackPlugin = require("html-webpack-plugin");
1515
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
1616

@@ -37,7 +37,7 @@ module.exports = (env, argv) => {
3737
},
3838
{
3939
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
40-
// For more information, see https://webpack.js.org/guides/asset-modules/.
40+
// For more information, see `Asset Modules <https://webpack.js.org/guides/asset-modules/>`_.
4141
type: "asset",
4242
},
4343
],
@@ -56,24 +56,24 @@ module.exports = (env, argv) => {
5656
},
5757
output: {
5858
path: path.resolve(__dirname, "runestone/dist"),
59-
// See https://webpack.js.org/guides/caching/. This provides a hash for dynamic imports as well, avoiding caching out-of-date JS.
60-
filename: "[name].bundle.js?v=[contenthash]",
61-
// Node 17.0 reports ``Error: error:0308010C:digital envelope routines::unsupported``. Per `SO <https://stackoverflow.com/a/69394785/16038919>`_, this error is produced by using an old, default hash that OpenSSL removed support for. The `webpack docs <https://webpack.js.org/configuration/output/#outputhashfunction>"__ says that ``xxhash64`` is a faster algorithm.
59+
// _`Output file naming`: see the `caching guide <https://webpack.js.org/guides/caching/>`_. This provides a hash for dynamic imports as well, avoiding caching out-of-date JS. Putting the hash in a query parameter (such as ``[name].js?v=[contenthash]``) causes the compression plugin to not update zipped files.
60+
filename: "[name].[contenthash].bundle.js",
61+
// Node 17.0 reports ``Error: error:0308010C:digital envelope routines::unsupported``. Per `SO <https://stackoverflow.com/a/69394785/16038919>`_, this error is produced by using an old, default hash that OpenSSL removed support for. The `webpack docs <https://webpack.js.org/configuration/output/#outputhashfunction>`__ say that ``xxhash64`` is a faster algorithm.
6262
hashFunction: "xxhash64",
6363
// Delete everything in the output directory on each build.
6464
clean: true,
6565
},
66-
// See https://webpack.js.org/guides/code-splitting/#splitchunksplugin.
66+
// See the `SplitChunksPlugin docs <https://webpack.js.org/guides/code-splitting/#splitchunksplugin>`_.
6767
optimization: {
6868
moduleIds: "deterministic",
6969
// Collect all the webpack import runtime into a single file, which is named ``runtime.bundle.js``. This must be statically imported by all pages containing Runestone components.
7070
runtimeChunk: "single",
7171
splitChunks: {
7272
chunks: "all",
7373
},
74-
// CSS for production was copied from https://webpack.js.org/plugins/mini-css-extract-plugin/#minimizing-for-production.
74+
// CSS for production was copied from `Minimizing For Production <https://webpack.js.org/plugins/mini-css-extract-plugin/#minimizing-for-production>`_.
7575
minimizer: [
76-
// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line.
76+
// For webpack@5 you can use the ``...`` syntax to extend existing minimizers (i.e. ``terser-webpack-plugin``), uncomment the next line.
7777
`...`,
7878
new CssMinimizerPlugin(),
7979
],
@@ -101,7 +101,8 @@ module.exports = (env, argv) => {
101101
],
102102
}),
103103
new MiniCssExtractPlugin({
104-
filename: "[name].css?v=[contenthash]",
104+
// See `output file naming`_.
105+
filename: "[name].[contenthash].css",
105106
chunkFilename: "[id].css",
106107
}),
107108
// Copied from the `webpack docs <https://webpack.js.org/plugins/compression-webpack-plugin>`_. This creates ``.gz`` versions of all files. The webserver in use needs to be configured to send this instead of the uncompressed versions.

0 commit comments

Comments
 (0)