diff --git a/test/tests/build.js b/test/tests/build.js index f13674c6..e4e5e825 100644 --- a/test/tests/build.js +++ b/test/tests/build.js @@ -19,6 +19,10 @@ describe("public folder", function () { expect(fs.existsSync(path.join(publicFolder, "thelounge.webmanifest"))).to.be.true; }); + it("audio files are copied", function () { + expect(fs.existsSync(path.join(publicFolder, "audio", "pop.wav"))).to.be.true; + }); + it("index HTML file is not copied", function () { expect(fs.existsSync(path.join(publicFolder, "index.html"))).to.be.false; expect(fs.existsSync(path.join(publicFolder, "index.html.tpl"))).to.be.false; @@ -32,6 +36,8 @@ describe("public folder", function () { it("style files are built", function () { expect(fs.existsSync(path.join(publicFolder, "css", "style.css"))).to.be.true; expect(fs.existsSync(path.join(publicFolder, "css", "style.css.map"))).to.be.true; + expect(fs.existsSync(path.join(publicFolder, "themes", "default.css"))).to.be.true; + expect(fs.existsSync(path.join(publicFolder, "themes", "morning.css"))).to.be.true; }); it("style files contain expected content", function (done) { @@ -55,4 +61,15 @@ describe("public folder", function () { expect(fs.existsSync(path.join(publicFolder, "js", "loading-error-handlers.js"))).to.be .true; }); + + it("service worker has cacheName set", function (done) { + fs.readFile(path.join(publicFolder, "service-worker.js"), "utf8", function (err, contents) { + expect(err).to.be.null; + + expect(contents.includes("const cacheName =")).to.be.true; + expect(contents.includes("__HASH__")).to.be.false; + + done(); + }); + }); }); diff --git a/webpack.config.js b/webpack.config.js index aba4eab8..9b0f764a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -91,42 +91,50 @@ const config = { new MiniCssExtractPlugin({ filename: "css/style.css", }), - new CopyPlugin([ - { - from: "./node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-900.woff*", - to: "fonts/[name].[ext]", - }, - { - from: "./client/js/loading-error-handlers.js", - to: "js/[name].[ext]", - }, - { - from: "./client/*", - to: "[name].[ext]", - ignore: ["index.html.tpl", "service-worker.js"], - }, - { - from: "./client/service-worker.js", - to: "[name].[ext]", - transform(content) { - return content - .toString() - .replace("__HASH__", isProduction ? Helper.getVersionCacheBust() : "dev"); + new CopyPlugin({ + patterns: [ + { + from: + "./node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-900.woff*", + to: "fonts/[name].[ext]", }, - }, - { - from: "./client/audio/*", - to: "audio/[name].[ext]", - }, - { - from: "./client/img/*", - to: "img/[name].[ext]", - }, - { - from: "./client/themes/*", - to: "themes/[name].[ext]", - }, - ]), + { + from: "./client/js/loading-error-handlers.js", + to: "js/[name].[ext]", + }, + { + from: "./client/*", + to: "[name].[ext]", + globOptions: { + ignore: ["**/index.html.tpl", "**/service-worker.js"], + }, + }, + { + from: "./client/service-worker.js", + to: "[name].[ext]", + transform(content) { + return content + .toString() + .replace( + "__HASH__", + isProduction ? Helper.getVersionCacheBust() : "dev" + ); + }, + }, + { + from: "./client/audio/*", + to: "audio/[name].[ext]", + }, + { + from: "./client/img/*", + to: "img/[name].[ext]", + }, + { + from: "./client/themes/*", + to: "themes/[name].[ext]", + }, + ], + }), // socket.io uses debug, we don't need it new webpack.NormalModuleReplacementPlugin( /debug/,