1
Fork 0
mirror of https://github.com/Steffo99/bluelib.git synced 2024-12-23 03:54:21 +00:00
bluelib/webpack.config.js

101 lines
2.9 KiB
JavaScript
Raw Normal View History

const path = require("path")
module.exports = {
// Mode: setting this to development preconfigure webpack with some defaults
2021-08-28 03:32:36 +00:00
mode: "production",
// Loaders: these allow various non-js filetypes to be imported
module: {
rules: [
{
test: /[.]css$/,
exclude: /node_modules/,
2021-08-28 03:28:28 +00:00
use: [
{
loader: "style-loader"
},
{
loader: "css-loader"
},
],
},
{
test: /[.]js$/,
exclude: /node_modules/,
2021-08-28 03:28:28 +00:00
use: [
{
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"]
},
}
],
},
{
test: /[.]jsx$/,
exclude: /node_modules/,
use: [{
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"]
},
}],
},
{
test: /[.]ts$/,
exclude: /node_modules/,
use: [{
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-typescript"]
},
}],
},
{
test: /[.]tsx$/,
exclude: /node_modules/,
use: [{
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-typescript", "@babel/preset-react"]
},
}],
},
],
},
// Resolve: how files should be imported
resolve: {
// These extensions should be loaded from the source code
extensions: [".tsx", ".ts", ".jsx", ".js"],
},
// Externals: these are the dependencies of the bundle
externals: {
"classnames": "commonjs classnames",
"color": "commonjs color",
"uuid": "commonjs uuid",
"react": "commonjs react",
"react-dom": "commonjs react-dom"
},
// Input: this is the source root file
entry: "./src/index.ts",
// Output: this is what webpack should build
output: {
path: path.resolve(__dirname, "dist"),
filename: "bluelib-react.umd.js",
library: {
name: "bluelib-react",
type: "umd",
},
// WHY?!
// https://stackoverflow.com/a/64639975/4334568
globalObject: 'this',
},
// Devtools: display source maps
// devtool: "inline-source-map",
}