From 6193ae49975e7bccac34c95b3d13d42f74d6fcee Mon Sep 17 00:00:00 2001 From: Bruce Martin Date: Mon, 6 Apr 2020 20:04:06 -0600 Subject: [PATCH] Cleanup front-end build and python module contents (#1350) * cleanup build and module contents * lint * update chalk * more cleanup * fix unit test --- Makefile | 2 +- .../webpack/webpack.config.dev.js | 37 +- .../webpack/webpack.config.prod.js | 52 +- client/index_template.html | 1 - client/package-lock.json | 5283 ++++++++++++++--- client/package.json | 52 +- common.mk | 5 +- server/app/app.py | 10 +- server/test/test_api.py | 2 +- 9 files changed, 4509 insertions(+), 935 deletions(-) diff --git a/Makefile b/Makefile index 3ba6d7f5..8d286cff 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ build-client: .PHONY: build-cli build-cli: build-client - git ls-files server/ | cpio -pdm $(BUILDDIR) + git ls-files server/ | grep -v 'server/test/' | cpio -pdm $(BUILDDIR) cp -r client/build/ $(CLIENTBUILD) $(call copy_client_assets,$(CLIENTBUILD),$(SERVERBUILD)) cp MANIFEST.in README.md setup.cfg setup.py $(BUILDDIR) diff --git a/client/configuration/webpack/webpack.config.dev.js b/client/configuration/webpack/webpack.config.dev.js index 73d06752..7191c812 100644 --- a/client/configuration/webpack/webpack.config.dev.js +++ b/client/configuration/webpack/webpack.config.dev.js @@ -2,6 +2,7 @@ const path = require("path"); const webpack = require("webpack"); const HtmlWebpackPlugin = require("html-webpack-plugin"); +const FaviconsWebpackPlugin = require("favicons-webpack-plugin"); const src = path.resolve("src"); const fonts = path.resolve("src/fonts"); @@ -60,30 +61,32 @@ module.exports = { { test: /\.json$/, include: [src, nodeModules], loader: "json-loader" }, { - test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)(\?.*)?$/, - include: nodeModules, + test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2|otf)$/i, loader: "file-loader", - query: { name: "static/media/[name].[ext]" } - }, - { - test: /\.(woff|woff2|eot|ttf|otf)$/, - include: fonts, - loader: "file-loader", - query: { name: "static/fonts/[name].[ext]" } - }, - { - test: /\.(mp4|webm)(\?.*)?$/, - include: [src, nodeModules], - loader: "url-loader", - query: { limit: 10000, name: "static/media/[name].[ext]" } + include: [nodeModules, fonts], + query: { name: "static/assets/[name].[ext]" } } ] }, plugins: [ new HtmlWebpackPlugin({ inject: true, - template: path.resolve("index.html"), - favicon: path.resolve("favicon.png") + template: path.resolve("index.html") + }), + new FaviconsWebpackPlugin({ + logo: "./favicon.png", + prefix: "static/img/", + favicons: { + icons: { + android: false, + appleIcon: false, + appleStartup: false, + coast: false, + firefox: false, + windows: false, + yandex: false + } + } }), new webpack.NoEmitOnErrorsPlugin(), new webpack.DefinePlugin({ diff --git a/client/configuration/webpack/webpack.config.prod.js b/client/configuration/webpack/webpack.config.prod.js index 2c4981a4..9cd53a9d 100644 --- a/client/configuration/webpack/webpack.config.prod.js +++ b/client/configuration/webpack/webpack.config.prod.js @@ -2,8 +2,9 @@ const path = require("path"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); -const SWPrecacheWebpackPlugin = require("sw-precache-webpack-plugin"); const HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin"); +const FaviconsWebpackPlugin = require("favicons-webpack-plugin"); +const { CleanWebpackPlugin } = require("clean-webpack-plugin"); const src = path.resolve("src"); const fonts = path.resolve("src/fonts"); @@ -17,11 +18,9 @@ module.exports = { mode: "production", bail: true, cache: false, - devtool: "cheap-source-map", entry: ["./src/index.js"], output: { path: path.resolve("build"), - filename: "static/js/[name].[chunkhash:8].js", publicPath }, module: { @@ -69,22 +68,10 @@ module.exports = { exclude: /manifest.json$/ }, { - test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)(\?.*)?$/, - include: nodeModules, + test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2|otf)$/i, loader: "file-loader", - query: { name: "static/media/[name].[ext]" } - }, - { - test: /\.(woff|woff2|eot|ttf|otf)$/, - include: fonts, - loader: "file-loader", - query: { name: "static/fonts/[name].[ext]" } - }, - { - test: /\.(mp4|webm)(\?.*)?$/, - include: [src, nodeModules], - loader: "url-loader", - query: { limit: 10000, name: "static/media/[name].[hash:8].[ext]" } + include: [nodeModules, fonts], + query: { name: "static/assets/[name]-[contenthash].[ext]" } } ] }, @@ -93,7 +80,6 @@ module.exports = { inject: "body", filename: "index.html", template: path.resolve("index_template.html"), - favicon: path.resolve("favicon.png"), inlineSource: ".(js|css)$", minify: { removeComments: true, @@ -108,14 +94,28 @@ module.exports = { minifyURLs: true } }), - new HtmlWebpackInlineSourcePlugin(), - new MiniCssExtractPlugin({ - filename: "static/css/[name].[contenthash:8].css" + new CleanWebpackPlugin({ + verbose: true, + protectWebpackAssets: false, + cleanAfterEveryBuildPatterns: ["main.js", "main.css"] }), - new SWPrecacheWebpackPlugin({ - cacheId: "cellxgene", - filename: "service-worker.js" - }) + new FaviconsWebpackPlugin({ + logo: "./favicon.png", + prefix: "static/assets/", + favicons: { + icons: { + android: false, + appleIcon: false, + appleStartup: false, + coast: false, + firefox: false, + windows: false, + yandex: false + } + } + }), + new HtmlWebpackInlineSourcePlugin(HtmlWebpackPlugin), + new MiniCssExtractPlugin() ], performance: { maxEntrypointSize: 2000000, diff --git a/client/index_template.html b/client/index_template.html index ff3eef0b..3fd56340 100644 --- a/client/index_template.html +++ b/client/index_template.html @@ -34,7 +34,6 @@ box-sizing: border-box; } -