-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
66 lines (65 loc) · 2.3 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = function (env, argv) {
return {
mode: argv.mode,
entry: "./src/index.ts",
output: {
path: path.resolve(__dirname, "lib"),
filename: env.cjs ? "cjs/index.js" : "esm/index.js",
library: "ui-library-testing-junaid",
libraryTarget: "umd",
umdNamedDefine: true,
globalObject: "typeof self !== 'undefined' ? self : this", // Required for server rendering
},
plugins: [
new MiniCssExtractPlugin({
filename: env.cjs ? "cjs/styles.css" : "esm/styles.css",
}),
],
module: {
rules: [
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [require("tailwindcss"), require("autoprefixer")],
},
},
},
],
},
{
test: /\.(js|ts)x?$/,
exclude: /node_modules/,
use: [
"babel-loader",
{
loader: "ts-loader",
options: {
configFile: env.cjs
? path.resolve(__dirname, "config", "tsconfig.cjs.json")
: "tsconfig.json",
},
},
],
},
],
},
devtool: "source-map",
target: "node",
resolve: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
externals: {
react: "commonjs react", // Tell webpack to use external versions of React and React DOM and Tailwind for server rendering
"react-dom": "commonjs react-dom",
tailwindcss: "tailwindcss",
},
};
};