startpage/webpack.config.js

64 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2020-04-22 13:13:33 +00:00
/* eslint-env node */
/* eslint-disable @typescript-eslint/no-var-requires */
2020-04-19 21:31:59 +00:00
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const path = require("path");
const DEVELOPMENT = process.env.NODE_ENV === "development";
2020-04-19 21:31:59 +00:00
module.exports = {
context: path.join(__dirname, "src"),
resolve: {
extensions: [".js", ".ts", ".tsx"]
},
entry: ["./index.tsx"],
output: {
path: path.join(__dirname, "dist"),
filename: "bundle.js"
},
devtool: DEVELOPMENT ? "source-map" : false,
2020-04-19 21:31:59 +00:00
devServer: {
2020-04-22 13:13:33 +00:00
contentBase: "./dist",
inline: true,
2020-04-19 21:31:59 +00:00
host: "localhost",
port: 8080,
2020-04-22 13:13:33 +00:00
stats: "errors-only",
liveReload: true,
watchContentBase: true
2020-04-19 21:31:59 +00:00
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
loader: "ts-loader"
},
{
test: /\.s[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader",
],
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: "file-loader",
options: {
name: "assets/img/[name].[ext]?[hash]"
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: "index.html",
template: "index.html",
hash: true,
minify: !DEVELOPMENT
2020-04-19 21:31:59 +00:00
}),
new MiniCssExtractPlugin()
]
};