Created
January 25, 2023 09:28
-
-
Save royib/c757e5828afde0ecca0aa1f1f1883419 to your computer and use it in GitHub Desktop.
bazel react webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require("path"); | |
const HtmlWebpackPlugin = require("html-webpack-plugin"); | |
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | |
module.exports = { | |
entry: "./src/index.js", | |
output: { | |
filename: "main.js", | |
path: path.resolve(__dirname, "dist"), | |
}, | |
plugins: [ | |
new HtmlWebpackPlugin({ | |
template: path.join(__dirname, "public", "index.html"), | |
}), | |
new MiniCssExtractPlugin() | |
], | |
devServer: { | |
static: { | |
directory: path.join(__dirname, "output"), | |
}, | |
port: 3000, | |
}, | |
module: { | |
// exclude node_modules | |
rules: [ | |
{ | |
test: /\.(js|jsx)$/, | |
exclude: /node_modules/, | |
use: ["babel-loader"], | |
}, | |
{ | |
test: /\.s[ac]ss$/i, | |
use: [ | |
MiniCssExtractPlugin.loader, | |
// Translates CSS into CommonJS | |
"css-loader", | |
// Compiles Sass to CSS | |
"sass-loader", | |
], | |
}, | |
{ | |
test: /\.svg$/i, | |
issuer: /\.[jt]sx?$/, | |
use: ['@svgr/webpack'], | |
}, | |
], | |
}, | |
// pass all js files through Babel | |
resolve: { | |
extensions: ["*", ".js", ".jsx"], | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment