projekt-sklep/webpack.config.js
2020-09-06 14:34:28 +02:00

62 lines
1.1 KiB
JavaScript

const path = require("path");
const process = require("process");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const mode = process.env.NODE_ENV || "development";
const src = path.resolve(__dirname, "src");
module.exports = {
entry: {
index: path.join(src, "index.ts"),
},
mode: mode,
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.(c|s[ac])ss$/i,
use: [
{
loader: "file-loader",
options: { name: "[name].css" },
},
"sass-loader",
],
},
{
test: /\.html$/,
use: [
"html-loader",
{
loader: "posthtml-loader",
options: {
plugins: [
/* PostHTML Plugins */
require("posthtml-extend")({ root: src }),
],
},
},
],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
},
plugins: [
new HtmlWebpackPlugin({
filename: "index.html",
template: path.resolve(src, "index.html"),
chunks: ["index"],
}),
],
};