mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-18 17:38:47 +08:00
* add sentry webpack plugin * allow override of webpack config * work around cheerio inability to parse jinga templates * webpack can not minify jinja templates * allow script injection to specify other attributes * allow script injection to specify other attributes * Adjustments to make plugin systems work * Add sourcemaps for javascript in prod webpack * Update .gitignore * Fix spelling errors Co-authored-by: Matt Weiden <538456+mweiden@users.noreply.github.com>
124 lines
3.1 KiB
JavaScript
124 lines
3.1 KiB
JavaScript
// jshint esversion: 6
|
|
const path = require("path");
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
|
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
const TerserJSPlugin = require("terser-webpack-plugin");
|
|
const CleanCss = require("clean-css");
|
|
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
|
|
|
const CspHashPlugin = require("./cspHashPlugin");
|
|
|
|
const src = path.resolve("src");
|
|
const fonts = path.resolve("src/fonts");
|
|
const nodeModules = path.resolve("node_modules");
|
|
|
|
const babelOptions = require("../babel/babel.prod");
|
|
|
|
const publicPath = "/";
|
|
|
|
module.exports = {
|
|
mode: "production",
|
|
bail: true,
|
|
cache: false,
|
|
entry: ["./src/index.js"],
|
|
output: {
|
|
filename: "static/[name]-[contenthash].js",
|
|
path: path.resolve("build"),
|
|
publicPath,
|
|
},
|
|
optimization: {
|
|
minimize: true,
|
|
minimizer: [
|
|
new TerserJSPlugin({}),
|
|
new OptimizeCSSAssetsPlugin({
|
|
cssProcessor: CleanCss,
|
|
}),
|
|
],
|
|
},
|
|
devtool: "source-map",
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.js$/,
|
|
include: src,
|
|
loader: "babel-loader",
|
|
options: babelOptions,
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
include: src,
|
|
exclude: [path.resolve(src, "index.css")],
|
|
use: [
|
|
MiniCssExtractPlugin.loader,
|
|
{
|
|
loader: "css-loader",
|
|
options: {
|
|
modules: {
|
|
localIdentName: "[name]__[local]___[hash:base64:5]",
|
|
},
|
|
importLoaders: 1,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
test: /index\.css$/,
|
|
include: [path.resolve(src, "index.css")],
|
|
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
|
},
|
|
{
|
|
test: /\.json$/,
|
|
include: [src, nodeModules],
|
|
loader: "json-loader",
|
|
exclude: /manifest.json$/,
|
|
},
|
|
{
|
|
test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2|otf)$/i,
|
|
loader: "file-loader",
|
|
include: [nodeModules, fonts],
|
|
query: { name: "static/assets/[name]-[contenthash].[ext]" },
|
|
},
|
|
],
|
|
},
|
|
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 FaviconsWebpackPlugin({
|
|
logo: "./favicon.png",
|
|
prefix: "static/assets/",
|
|
favicons: {
|
|
icons: {
|
|
android: false,
|
|
appleIcon: false,
|
|
appleStartup: false,
|
|
coast: false,
|
|
firefox: false,
|
|
windows: false,
|
|
yandex: false,
|
|
},
|
|
},
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: "static/[name]-[contenthash].css",
|
|
}),
|
|
new CspHashPlugin({
|
|
filename: "csp-hashes.json",
|
|
}),
|
|
],
|
|
performance: {
|
|
maxEntrypointSize: 2000000,
|
|
maxAssetSize: 2000000,
|
|
},
|
|
};
|