Skip to content

Instantly share code, notes, and snippets.

@limejoe
Created October 9, 2020 13:14
Show Gist options
  • Save limejoe/04e87d012f0c27e1983a3a6da0c6be64 to your computer and use it in GitHub Desktop.
Save limejoe/04e87d012f0c27e1983a3a6da0c6be64 to your computer and use it in GitHub Desktop.
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const ESLintPlugin = require("eslint-webpack-plugin");
const extensionsToResolve = [".ts", ".tsx", ".js", ".json"];
module.exports = {
entry: "./src/index.tsx",
devtool: "inline-source-map",
output: {
filename: "[name].[chunkhash].bundle.js",
path: path.resolve(__dirname + "/dist")
},
resolve: {
extensions: extensionsToResolve,
plugins: [new TsconfigPathsPlugin({ extensions: extensionsToResolve })]
},
module: {
rules: [
{
test: /\.ts(x?)$/,
enforce: "pre",
use: ["ts-loader"]
},
{
test: /\.(s*)css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: { modules: { auto: true, localIdentName: "[local]--[hash:base64]" } }
},
"sass-loader"
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html",
filename: "index.html"
}),
new MiniCssExtractPlugin({
filename: "[name].[chunkhash].css",
chunkFilename: "[id].[chunkhash].css"
}),
new CleanWebpackPlugin(),
new ESLintPlugin({ extensions: ["ts", "tsx"], failOnError: true })
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment