Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
141 lines (139 loc) · 4.18 KB
/
Copy pathwebpack.config.js
File metadata and controls
141 lines (139 loc) · 4.18 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
// const removeDuplicates = require("./remove-dups.js"); // Adjust the path as necessary
const path = require("path");
// const million = require("million/compiler");
// const { millionConfig } = require('./next.config.js');
const webpack = require("webpack");
// const AddImportantPlugin = require("./add-important-styles.js"); // Import the custom plugin
module.exports = (env) => {
const dir = env.dir || `/tmp/replace_me`;
return {
mode: "production",
entry: "./src/app/Components/root_build.js",
output: {
path: dir,
filename: "vg_bundle.js",
},
resolve: {
alias: {
"@vg-edge": path.resolve(__dirname, "vg-edge"),
"@main": path.resolve(__dirname, "vg-docker/src"),
"@monorepo": path.resolve(__dirname),
"@": path.resolve(__dirname, "src"),
"@server": path.resolve(__dirname, "vg-docker"),
"@nextui-org/react": path.resolve(
__dirname,
`src`,
`nextui-fork`,
`nextui`,
`packages`,
`core`,
`react`
),
"@nextui-org/theme": path.resolve(
__dirname,
`src`,
`nextui-fork`,
`nextui`,
`packages`,
`core`,
`theme`
),
react: path.resolve(__dirname, `node_modules`, `react`),
// "react-dom/test-utils": "preact/test-utils",
"react-dom": path.resolve(__dirname, `node_modules`, `react-dom`),
// "react/jsx-runtime": "preact/jsx-runtime"
},
extensions: [".ts", ".tsx", ".js", ".jsx"],
},
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
exclude: /node_modules/,
loader: "babel-loader",
options: {
presets: [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript",
"next/babel",
],
plugins: [
"./babel-react-prefix-classnames.js",
// ["@babel/plugin-transform-react-jsx", {
// "pragma": "h",
// "pragmaFrag": "Fragment",
// }]
],
},
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [
require("autoprefixer"),
require("tailwindcss"),
require("postcss-prefixer")({
prefix: "vg-",
}),
require("postcss-selector-namespace")({
namespace: ".vg-render-container", // Replace with your desired ID
}),
// require('postcss-safe-important')(), // This will add !important to all styles
],
},
},
},
],
},
],
},
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
// Enable/disable options as needed
compress: {
drop_console: true, // Remove console.* calls
},
output: {
comments: false, // Remove comments
},
},
extractComments: false, // Don't extract comments to a separate file
}),
new CssMinimizerPlugin(),
],
},
plugins: [
new MiniCssExtractPlugin({
filename: "styles.css",
}),
new AddImportantPlugin(), // Add the custom plugin
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production"),
WORKER_ENV: JSON.stringify("production"),
},
}),
// million.webpack({
// auto: {
// rsc: true,
// threshold: 0.25, // default: 0.1,
// skip: [/nextui/g],
// mute: true
// },
// mute: true
// })
],
};
};