phantasmal-world/webpack.prod.js
2020-07-19 00:36:35 +02:00

46 lines
1.3 KiB
JavaScript

const common = require("./webpack.common.js");
const path = require("path");
const { merge } = require("webpack-merge");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const Dotenv = require("dotenv-webpack");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = merge(common, {
mode: "production",
output: {
filename: "[name].[contenthash].js",
},
module: {
rules: [
{
test: /\.ts$/,
loader: "ts-loader",
include: path.resolve(__dirname, "src"),
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
],
},
plugins: [
new CleanWebpackPlugin(),
new Dotenv({
path: "./.env.prod",
}),
new MiniCssExtractPlugin({
ignoreOrder: true,
filename: "[name].[contenthash].css",
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, "assets"),
to: path.resolve(__dirname, "dist/assets"),
},
],
}),
],
});