2020-04-12 03:44:41 +03:00
|
|
|
const webpack = require("webpack");
|
|
|
|
const path = require("path");
|
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
|
const webpackBundleAnalyzer = require("webpack-bundle-analyzer");
|
|
|
|
|
|
|
|
process.env.NODE_ENV = "production";
|
2020-05-03 01:32:15 +03:00
|
|
|
process.env.PUBLIC_URL = "/rxc-app";
|
2020-04-12 03:44:41 +03:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
mode: "production",
|
|
|
|
target: "web",
|
|
|
|
devtool: "source-map",
|
|
|
|
entry: "./src/index",
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, "build"),
|
2020-05-03 01:32:15 +03:00
|
|
|
publicPath: process.env.PUBLIC_URL,
|
2020-04-12 03:44:41 +03:00
|
|
|
filename: "bundle.js"
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
// Display bundle stats
|
|
|
|
new webpackBundleAnalyzer.BundleAnalyzerPlugin({ analyzerMode: "static" }),
|
|
|
|
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: "[name].[contenthash].css"
|
|
|
|
}),
|
|
|
|
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
// This global makes sure React is built in prod mode.
|
|
|
|
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
|
2020-05-03 01:32:15 +03:00
|
|
|
"process.env.PUBLIC_URL": JSON.stringify(process.env.PUBLIC_URL),
|
|
|
|
"process.env.API_URL": JSON.stringify("http://toodle.ddns.net/rxc-api")
|
2020-04-12 03:44:41 +03:00
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: "src/index.html",
|
|
|
|
favicon: "src/favicon.ico",
|
|
|
|
minify: {
|
|
|
|
// see https://github.com/kangax/html-minifier#options-quick-reference
|
|
|
|
removeComments: true,
|
|
|
|
collapseWhitespace: true,
|
|
|
|
removeRedundantAttributes: true,
|
|
|
|
useShortDoctype: true,
|
|
|
|
removeEmptyAttributes: true,
|
|
|
|
removeStyleLinkTypeAttributes: true,
|
|
|
|
keepClosingSlash: true,
|
|
|
|
minifyJS: true,
|
|
|
|
minifyCSS: true,
|
|
|
|
minifyURLs: true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(js|jsx)$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: ["babel-loader", "eslint-loader"]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /(\.css)$/,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
{
|
|
|
|
loader: "css-loader",
|
|
|
|
options: {
|
|
|
|
sourceMap: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: "postcss-loader",
|
|
|
|
options: {
|
|
|
|
plugins: () => [require("cssnano")],
|
|
|
|
sourceMap: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|