Skip to content

Instantly share code, notes, and snippets.

@kiishi
Created August 31, 2019 17:41
Show Gist options
  • Select an option

  • Save kiishi/d6bf2c1b75c81bac14b75d007e9de744 to your computer and use it in GitHub Desktop.

Select an option

Save kiishi/d6bf2c1b75c81bac14b75d007e9de744 to your computer and use it in GitHub Desktop.
personal webpack config TS
# install these
-style-loader
-sass-loader
-css-loader
-wepack
-webpack-cli
-terser-webapack-plugin
#now the code (for react )
const path = require("path");
const terser = require('terser-webpack-plugin')
module.exports = {
entry: "./index.tsx",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/
},
{
test: /\.css$/,
use: [
{ loader: "style-loader" },
{
loader: "css-loader",
options: {
modules: true
}
}
]
},
{
test: /\.scss$/,
use: ["style-loader" , "css-loader","sass-loader"],
exclude: /node_modules/
}
]
},
plugins:[
new terser()
],
devServer: {
contentBase: "dist/",
watchContentBase: true,
hot: true
},
resolve: {
extensions: [".tsx", ".ts", ".js"]
},
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist")
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment