Skip to content

Instantly share code, notes, and snippets.

@mizchi
Created April 3, 2019 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mizchi/c0c59141c49dca90f1e44395895dc009 to your computer and use it in GitHub Desktop.
Save mizchi/c0c59141c49dca90f1e44395895dc009 to your computer and use it in GitHub Desktop.
const path = require("path");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
entry: {
"main": "src/index"
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name]-[contenthash].js",
chunkFilename: "[name]-[chunkhash].js"
},
resolve: {
modules: [path.resolve("./src"), path.resolve("./node_modules")],
extensions: [".ts", ".tsx", ".js", ".jsx"]
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
options: {
transpileOnly: true
}
}
]
},
optimization: {
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: false
})
],
splitChunks: {
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
name: "vendors",
filename: "vendors.[chunkhash].js",
reuseExistingChunk: true,
chunks: "all"
}
}
}
},
plugins: [
new CleanWebpackPlugin()
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment