mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-21 01:08:12 +08:00
* Replace optimize-css-assets-webpack-plugin with css-minimizer-webpack-plugin * Fix lint issues in JS * remove favicons * update snapshots * update annotations snapshots Co-authored-by: Trent Smith <1429913+Bento007@users.noreply.github.com> Co-authored-by: Seve Badajoz <sbadajoz@chanzuckerberg.com>
87 lines
2.3 KiB
JavaScript
87 lines
2.3 KiB
JavaScript
const path = require("path");
|
|
const webpack = require("webpack");
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
const TerserJSPlugin = require("terser-webpack-plugin");
|
|
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
|
const { merge } = require("webpack-merge");
|
|
|
|
const babelOptions = require("../babel/babel.prod");
|
|
|
|
const CspHashPlugin = require("./cspHashPlugin");
|
|
const sharedConfig = require("./webpack.config.shared");
|
|
|
|
const fonts = path.resolve("src/fonts");
|
|
const nodeModules = path.resolve("node_modules");
|
|
|
|
const prodConfig = {
|
|
mode: "production",
|
|
bail: true,
|
|
cache: false,
|
|
output: {
|
|
filename: "static/[name]-[contenthash].js",
|
|
},
|
|
optimization: {
|
|
minimize: true,
|
|
minimizer: [
|
|
new TerserJSPlugin({}),
|
|
new CssMinimizerPlugin({
|
|
minify: CssMinimizerPlugin.cleanCssMinify,
|
|
}),
|
|
],
|
|
},
|
|
devtool: "source-map",
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.jsx?$/,
|
|
loader: "babel-loader",
|
|
options: babelOptions,
|
|
},
|
|
{
|
|
test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2|otf)$/i,
|
|
loader: "file-loader",
|
|
include: [nodeModules, fonts],
|
|
options: {
|
|
name: "static/assets/[name]-[contenthash].[ext]",
|
|
// (thuang): This is needed to make sure @font url path is '../static/assets/'
|
|
publicPath: "static/",
|
|
},
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
filename: "index.html",
|
|
template: path.resolve("index_template.html"),
|
|
decodeEntities: false,
|
|
minify: false,
|
|
}),
|
|
new CleanWebpackPlugin({
|
|
verbose: true,
|
|
protectWebpackAssets: false,
|
|
cleanAfterEveryBuildPatterns: ["main.js", "main.css"],
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: "static/[name]-[contenthash].css",
|
|
}),
|
|
new CspHashPlugin({
|
|
filename: "csp-hashes.json",
|
|
}),
|
|
new webpack.DefinePlugin({
|
|
// webpack 5 no longer polyfills NodeJS modules, so fake the one we need
|
|
"process.env": JSON.stringify({
|
|
NODE_ENV: "production",
|
|
}),
|
|
}),
|
|
],
|
|
performance: {
|
|
maxEntrypointSize: 2000000,
|
|
maxAssetSize: 2000000,
|
|
},
|
|
};
|
|
|
|
module.exports = merge(sharedConfig, prodConfig);
|