@clikvn/showroom-visualizer 0.2.2-dev-12 → 0.2.2-dev-13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -133
- package/base.json +21 -21
- package/dist/components/SkinLayer/Floorplan/Map.d.ts.map +1 -1
- package/dist/components/SkinLayer/Floorplan/Minimap/MiniMapMarker.d.ts.map +1 -1
- package/dist/components/SkinLayer/Floorplan/Minimap/index.d.ts.map +1 -1
- package/dist/components/SkinLayer/Layout/index.d.ts.map +1 -1
- package/dist/components/SkinLayer/index.d.ts +0 -32
- package/dist/components/SkinLayer/index.d.ts.map +1 -1
- package/dist/features/ShowroomVisualizer/VirtualTour.d.ts +0 -5
- package/dist/features/ShowroomVisualizer/VirtualTour.d.ts.map +1 -1
- package/dist/features/ShowroomVisualizer/VirtualTourContainer.d.ts +3 -4
- package/dist/features/ShowroomVisualizer/VirtualTourContainer.d.ts.map +1 -1
- package/dist/features/ShowroomVisualizer/index.d.ts +3 -24
- package/dist/features/ShowroomVisualizer/index.d.ts.map +1 -1
- package/dist/fonts/icomoon.svg +633 -633
- package/dist/hooks/useToolConfig.d.ts.map +1 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.html +27 -102
- package/dist/models/Visualizer/Tour.d.ts +1 -0
- package/dist/models/Visualizer/Tour.d.ts.map +1 -1
- package/dist/models/Visualizer/TourScenario/TourScenarioPlayer.d.ts +1 -0
- package/dist/models/Visualizer/TourScenario/TourScenarioPlayer.d.ts.map +1 -1
- package/dist/register.d.ts +0 -3
- package/dist/register.d.ts.map +1 -1
- package/dist/types/SkinLayer/tool.type.d.ts +1 -6
- package/dist/types/SkinLayer/tool.type.d.ts.map +1 -1
- package/dist/types/SkinLayer/visualizer.type.d.ts +0 -3
- package/dist/types/SkinLayer/visualizer.type.d.ts.map +1 -1
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +1 -1
- package/package.json +1 -9
- package/rollup.config.js +97 -427
- package/tailwind.config.cjs +151 -151
- package/.idea/inspectionProfiles/Project_Default.xml +0 -36
- package/.idea/jsLinters/eslint.xml +0 -7
- package/.idea/misc.xml +0 -9
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -8
- package/.idea/showroom-visualizer.iml +0 -9
- package/.idea/vcs.xml +0 -6
- package/DEVELOPMENT.md +0 -120
- package/EXAMPLES.md +0 -967
- package/SETUP_COMPLETE.md +0 -149
- package/dist/components/SkinLayer/DefaultLayout/index.d.ts +0 -8
- package/dist/components/SkinLayer/DefaultLayout/index.d.ts.map +0 -1
- package/dist/components/SkinLayer/GalleryFullScreen/Content/ARViewer.d.ts +0 -30
- package/dist/components/SkinLayer/GalleryFullScreen/Content/ARViewer.d.ts.map +0 -1
- package/dist/components/SkinLayer/ModalItemInfo/Description.d.ts +0 -10
- package/dist/components/SkinLayer/ModalItemInfo/Description.d.ts.map +0 -1
- package/dist/components/SkinLayer/ModalItemInfo/Intro.d.ts +0 -9
- package/dist/components/SkinLayer/ModalItemInfo/Intro.d.ts.map +0 -1
- package/dist/components/SkinLayer/ModalItemInfo/Media.d.ts +0 -13
- package/dist/components/SkinLayer/ModalItemInfo/Media.d.ts.map +0 -1
- package/dist/components/SkinLayer/ModalItemInfo/index.d.ts +0 -10
- package/dist/components/SkinLayer/ModalItemInfo/index.d.ts.map +0 -1
- package/dist/components/SkinLayer/PoiTextureOptions/HorizontalMenu/index.d.ts +0 -13
- package/dist/components/SkinLayer/PoiTextureOptions/HorizontalMenu/index.d.ts.map +0 -1
- package/dist/components/SkinLayer/PoiTextureOptions/SemicircleMenu/index.d.ts +0 -13
- package/dist/components/SkinLayer/PoiTextureOptions/SemicircleMenu/index.d.ts.map +0 -1
- package/dist/components/SkinLayer/PoiTextureOptions/TextureMenuItem/index.d.ts +0 -15
- package/dist/components/SkinLayer/PoiTextureOptions/TextureMenuItem/index.d.ts.map +0 -1
- package/dist/components/SkinLayer/PoiTextureOptions/VerticalMenu/index.d.ts +0 -13
- package/dist/components/SkinLayer/PoiTextureOptions/VerticalMenu/index.d.ts.map +0 -1
- package/dist/context/CustomLayoutContext.d.ts +0 -20
- package/dist/context/CustomLayoutContext.d.ts.map +0 -1
- package/dist/context/StoreContext.d.ts +0 -5
- package/dist/context/StoreContext.d.ts.map +0 -1
- package/dist/features/ShowroomVisualizer/Scripts.d.ts +0 -4
- package/dist/features/ShowroomVisualizer/Scripts.d.ts.map +0 -1
- package/dist/features/ShowroomVisualizer/TourContainer.d.ts +0 -9
- package/dist/features/ShowroomVisualizer/TourContainer.d.ts.map +0 -1
- package/dist/features/ShowroomVisualizer/Tours.d.ts +0 -3
- package/dist/features/ShowroomVisualizer/Tours.d.ts.map +0 -1
- package/dist/hooks/Visualizer/reducer.d.ts +0 -116
- package/dist/hooks/Visualizer/reducer.d.ts.map +0 -1
- package/dist/hooks/headless/index.d.ts +0 -150
- package/dist/hooks/headless/index.d.ts.map +0 -1
- package/dist/hooks/headless/useFloorplanControl.d.ts +0 -18
- package/dist/hooks/headless/useFloorplanControl.d.ts.map +0 -1
- package/dist/hooks/headless/usePOIInteraction.d.ts +0 -23
- package/dist/hooks/headless/usePOIInteraction.d.ts.map +0 -1
- package/dist/hooks/headless/useScenarioControl.d.ts +0 -22
- package/dist/hooks/headless/useScenarioControl.d.ts.map +0 -1
- package/dist/hooks/headless/useSceneNavigation.d.ts +0 -26
- package/dist/hooks/headless/useSceneNavigation.d.ts.map +0 -1
- package/dist/hooks/headless/useTourCore.d.ts +0 -23
- package/dist/hooks/headless/useTourCore.d.ts.map +0 -1
- package/dist/hooks/headless/useViewportControl.d.ts +0 -22
- package/dist/hooks/headless/useViewportControl.d.ts.map +0 -1
- package/dist/index.js +0 -1
- package/dist/types/custom-layout.d.ts +0 -63
- package/dist/types/custom-layout.d.ts.map +0 -1
- package/example/CSS_HANDLING.md +0 -141
- package/example/FIXES_SUMMARY.md +0 -121
- package/example/PATH_ALIASES.md +0 -103
- package/example/README.md +0 -64
- package/example/index.html +0 -13
- package/example/package.json +0 -25
- package/example/postcss.config.cjs +0 -6
- package/example/tailwind.config.cjs +0 -12
- package/example/tsconfig.node.json +0 -12
- package/example/vite.config.ts +0 -126
package/package.json
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clikvn/showroom-visualizer",
|
|
3
3
|
"description": "Showroom Visualizer",
|
|
4
|
-
"version": "0.2.2-dev-
|
|
4
|
+
"version": "0.2.2-dev-13",
|
|
5
5
|
"author": "Clik JSC",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"import": "./dist/index.js"
|
|
14
|
-
},
|
|
15
|
-
"./dist/web": "./dist/web.js",
|
|
16
|
-
"./dist/web.js": "./dist/web.js"
|
|
17
|
-
},
|
|
18
10
|
"scripts": {
|
|
19
11
|
"dev": "rollup --watch --config rollup.config.js",
|
|
20
12
|
"build": "rollup --config rollup.config.js",
|
package/rollup.config.js
CHANGED
|
@@ -1,427 +1,97 @@
|
|
|
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
|
-
// First, remove any findDOMNode from named imports
|
|
99
|
-
fixed = fixed.replace(
|
|
100
|
-
/import\s*\{([^}]*)\}\s*from\s*['"]react-dom['"]/g,
|
|
101
|
-
(match, imports) => {
|
|
102
|
-
if (imports.includes('findDOMNode')) {
|
|
103
|
-
const cleanedImports = imports
|
|
104
|
-
.split(',')
|
|
105
|
-
.map((imp) => imp.trim())
|
|
106
|
-
.filter((imp) => !imp.includes('findDOMNode'))
|
|
107
|
-
.join(', ');
|
|
108
|
-
|
|
109
|
-
if (cleanedImports.trim()) {
|
|
110
|
-
return `import { ${cleanedImports} } from 'react-dom'`;
|
|
111
|
-
}
|
|
112
|
-
return '';
|
|
113
|
-
}
|
|
114
|
-
return match;
|
|
115
|
-
}
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
// Handle combined default and named imports
|
|
119
|
-
fixed = fixed.replace(
|
|
120
|
-
/import\s+(\w+),\s*\{\s*([^}]+)\s*\}\s*from\s*['"]react-dom['"]/g,
|
|
121
|
-
(match, defaultImport, namedImports) => {
|
|
122
|
-
// Check if named imports contains invalid syntax like "ReactDOM__default.createPortal"
|
|
123
|
-
if (
|
|
124
|
-
namedImports.includes('ReactDOM__default.') ||
|
|
125
|
-
namedImports.includes('findDOMNode')
|
|
126
|
-
) {
|
|
127
|
-
// Extract valid imports only
|
|
128
|
-
const validImports = namedImports
|
|
129
|
-
.split(',')
|
|
130
|
-
.map((imp) => imp.trim())
|
|
131
|
-
.filter((imp) => {
|
|
132
|
-
// Remove any import that has dots or includes findDOMNode
|
|
133
|
-
return !imp.includes('.') && !imp.includes('findDOMNode');
|
|
134
|
-
})
|
|
135
|
-
.map((imp) => {
|
|
136
|
-
// Clean up "as" aliases
|
|
137
|
-
const parts = imp.split(/\s+as\s+/);
|
|
138
|
-
if (parts.length === 2 && !parts[0].includes('.')) {
|
|
139
|
-
return imp;
|
|
140
|
-
}
|
|
141
|
-
return '';
|
|
142
|
-
})
|
|
143
|
-
.filter(Boolean)
|
|
144
|
-
.join(', ');
|
|
145
|
-
|
|
146
|
-
if (validImports) {
|
|
147
|
-
return `import ${defaultImport}, { ${validImports} } from 'react-dom'`;
|
|
148
|
-
}
|
|
149
|
-
return `import ${defaultImport} from 'react-dom'`;
|
|
150
|
-
}
|
|
151
|
-
return match;
|
|
152
|
-
}
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
// Replace all variations of findDOMNode (but not in function declarations)
|
|
156
|
-
fixed = fixed.replace(/\bfindDOMNode\$?\d*\b/g, (match, offset) => {
|
|
157
|
-
// Check if this is a function declaration
|
|
158
|
-
const beforeMatch = fixed.substring(Math.max(0, offset - 20), offset);
|
|
159
|
-
if (beforeMatch.trim().endsWith('function')) {
|
|
160
|
-
return match; // Don't replace in function declarations
|
|
161
|
-
}
|
|
162
|
-
return 'ReactDOM__default.findDOMNode';
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// Fix property access patterns
|
|
166
|
-
fixed = fixed.replace(/(\w+)\.findDOMNode\b/g, (match, obj) => {
|
|
167
|
-
if (obj === 'ReactDOM__default') return match;
|
|
168
|
-
return 'ReactDOM__default.findDOMNode';
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// Replace other methods - but NOT when they're being used in import statements
|
|
172
|
-
const methodsToReplace = [
|
|
173
|
-
'createPortal',
|
|
174
|
-
'unstable_batchedUpdates',
|
|
175
|
-
'flushSync',
|
|
176
|
-
];
|
|
177
|
-
|
|
178
|
-
methodsToReplace.forEach((method) => {
|
|
179
|
-
// Only replace when not in import context
|
|
180
|
-
const regex = new RegExp(
|
|
181
|
-
`\\b${method}\\$?\\d*\\b(?![:\\.]|\\s*as\\s*\\w+)`,
|
|
182
|
-
'g'
|
|
183
|
-
);
|
|
184
|
-
fixed = fixed.replace(regex, (match, offset) => {
|
|
185
|
-
// Check if this is within an import statement
|
|
186
|
-
const beforeMatch = fixed.substring(Math.max(0, offset - 100), offset);
|
|
187
|
-
if (beforeMatch.includes('import') && beforeMatch.includes('{')) {
|
|
188
|
-
return match;
|
|
189
|
-
}
|
|
190
|
-
return `ReactDOM__default.${method}`;
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
return { code: fixed, map: null };
|
|
195
|
-
},
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
// ============================================================================
|
|
199
|
-
// CONFIG CHO NPM PACKAGE - External React
|
|
200
|
-
// ============================================================================
|
|
201
|
-
// Dùng khi: import { ShowroomVisualizer } from '@clikvn/showroom-visualizer'
|
|
202
|
-
// - React được external → Dùng React version của host app (Next.js, React app)
|
|
203
|
-
// - Cho phép custom layout overrides vì share cùng React instance
|
|
204
|
-
// - File nhỏ hơn vì không bundle React
|
|
205
|
-
const indexConfig = {
|
|
206
|
-
context: 'this',
|
|
207
|
-
|
|
208
|
-
// ✅ External React - Library sẽ dùng React từ host app
|
|
209
|
-
external: ['react', 'react-dom', 'react/jsx-runtime', 'react-dom/client'],
|
|
210
|
-
|
|
211
|
-
onwarn(warning, warn) {
|
|
212
|
-
// Bỏ qua warning về "use client" directive
|
|
213
|
-
if (
|
|
214
|
-
warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
|
|
215
|
-
warning.message.includes('"use client"')
|
|
216
|
-
) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
// Hiển thị các warning khác
|
|
220
|
-
warn(warning);
|
|
221
|
-
},
|
|
222
|
-
plugins: [
|
|
223
|
-
resolve({
|
|
224
|
-
extensions,
|
|
225
|
-
browser: true,
|
|
226
|
-
preferBuiltins: false,
|
|
227
|
-
dedupe: [
|
|
228
|
-
'react',
|
|
229
|
-
'react-dom',
|
|
230
|
-
'useTranslation',
|
|
231
|
-
'i18n',
|
|
232
|
-
'I18nextProvider',
|
|
233
|
-
],
|
|
234
|
-
}),
|
|
235
|
-
commonjs({
|
|
236
|
-
esmExternals: true,
|
|
237
|
-
requireReturnsDefault: 'auto',
|
|
238
|
-
// Không extract named imports từ external modules
|
|
239
|
-
ignoreDynamicRequires: false,
|
|
240
|
-
}),
|
|
241
|
-
// Skip uglify in dev mode - tốn thời gian
|
|
242
|
-
// uglify does not support ES2015+ properly — and React’s ESM builds rely heavily on ES2015+ semantics
|
|
243
|
-
// !isDev && uglify(),
|
|
244
|
-
json(),
|
|
245
|
-
// Skip babel in dev mode - giảm thời gian compile
|
|
246
|
-
!isDev &&
|
|
247
|
-
babel({
|
|
248
|
-
babelHelpers: 'bundled',
|
|
249
|
-
exclude: 'node_modules/**',
|
|
250
|
-
extensions,
|
|
251
|
-
}),
|
|
252
|
-
copy({
|
|
253
|
-
targets: [
|
|
254
|
-
{
|
|
255
|
-
src: [
|
|
256
|
-
'src/assets/fonts/icomoon.woff',
|
|
257
|
-
'src/assets/fonts/icomoon.ttf',
|
|
258
|
-
'src/assets/fonts/icomoon.svg',
|
|
259
|
-
'src/assets/fonts/icomoon.eot',
|
|
260
|
-
],
|
|
261
|
-
dest: 'fonts',
|
|
262
|
-
},
|
|
263
|
-
],
|
|
264
|
-
}),
|
|
265
|
-
replace({
|
|
266
|
-
'process.env.NODE_ENV': JSON.stringify(
|
|
267
|
-
isDev ? 'development' : 'production'
|
|
268
|
-
),
|
|
269
|
-
}),
|
|
270
|
-
postcss({
|
|
271
|
-
plugins: [autoprefixer(), tailwindcss()],
|
|
272
|
-
extract: false,
|
|
273
|
-
modules: false,
|
|
274
|
-
autoModules: false,
|
|
275
|
-
minimize: !isDev, // Skip minify CSS trong dev
|
|
276
|
-
inject: false,
|
|
277
|
-
}),
|
|
278
|
-
typescript({
|
|
279
|
-
sourceMap: isDev, // Source map chỉ trong dev
|
|
280
|
-
inlineSources: isDev,
|
|
281
|
-
}),
|
|
282
|
-
typescriptPaths({ preserveExtensions: true }),
|
|
283
|
-
// Skip terser trong dev - tốn rất nhiều thời gian
|
|
284
|
-
!isDev && terser({ output: { comments: false } }),
|
|
285
|
-
// ⚠️ QUAN TRỌNG: Fix react-dom imports sau khi bundle
|
|
286
|
-
// Phải đặt ở cuối để chạy sau tất cả transformations
|
|
287
|
-
fixReactDomImports(),
|
|
288
|
-
].filter(Boolean), // Remove false values
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
// ============================================================================
|
|
292
|
-
// CONFIG CHO WEB COMPONENT - Bundled React
|
|
293
|
-
// ============================================================================
|
|
294
|
-
// Dùng khi: <script src="web.js"> hoặc dynamic import('web.js')
|
|
295
|
-
// - React được BUNDLE vào → Standalone, không cần dependencies
|
|
296
|
-
// - KHÔNG hỗ trợ custom layout overrides (vì khác React instance với host app)
|
|
297
|
-
// - File lớn hơn vì bundle React (~200KB extra)
|
|
298
|
-
// - Phù hợp cho vanilla JS/HTML projects
|
|
299
|
-
const browserConfig = {
|
|
300
|
-
context: 'this',
|
|
301
|
-
// ❌ KHÔNG external React - Bundle React version 19 vào file
|
|
302
|
-
// external: [], // Không khai báo external = bundle tất cả
|
|
303
|
-
onwarn: indexConfig.onwarn,
|
|
304
|
-
plugins: [
|
|
305
|
-
resolve({
|
|
306
|
-
browser: true,
|
|
307
|
-
extensions: ['.ts', '.tsx', '.js'],
|
|
308
|
-
dedupe: ['react', 'react-dom'],
|
|
309
|
-
preferBuiltins: false,
|
|
310
|
-
}),
|
|
311
|
-
|
|
312
|
-
commonjs({
|
|
313
|
-
esmExternals: true,
|
|
314
|
-
requireReturnsDefault: 'auto',
|
|
315
|
-
}),
|
|
316
|
-
|
|
317
|
-
json(),
|
|
318
|
-
!isDev &&
|
|
319
|
-
babel({
|
|
320
|
-
babelHelpers: 'bundled',
|
|
321
|
-
extensions: ['.ts', '.tsx', '.js'],
|
|
322
|
-
exclude: 'node_modules/**',
|
|
323
|
-
}),
|
|
324
|
-
|
|
325
|
-
replace({
|
|
326
|
-
'process.env.NODE_ENV': JSON.stringify(
|
|
327
|
-
isDev ? 'development' : 'production'
|
|
328
|
-
),
|
|
329
|
-
preventAssignment: true,
|
|
330
|
-
}),
|
|
331
|
-
|
|
332
|
-
postcss({
|
|
333
|
-
plugins: [autoprefixer(), tailwindcss()],
|
|
334
|
-
extract: false,
|
|
335
|
-
modules: false,
|
|
336
|
-
autoModules: false,
|
|
337
|
-
minimize: !isDev,
|
|
338
|
-
inject: false,
|
|
339
|
-
}),
|
|
340
|
-
|
|
341
|
-
typescript({
|
|
342
|
-
sourceMap: isDev,
|
|
343
|
-
inlineSources: isDev,
|
|
344
|
-
}),
|
|
345
|
-
|
|
346
|
-
typescriptPaths({ preserveExtensions: true }),
|
|
347
|
-
!isDev &&
|
|
348
|
-
terser({
|
|
349
|
-
format: { comments: false },
|
|
350
|
-
}),
|
|
351
|
-
|
|
352
|
-
copy({
|
|
353
|
-
targets: [
|
|
354
|
-
{
|
|
355
|
-
src: [
|
|
356
|
-
'src/assets/fonts/icomoon.woff',
|
|
357
|
-
'src/assets/fonts/icomoon.ttf',
|
|
358
|
-
'src/assets/fonts/icomoon.svg',
|
|
359
|
-
'src/assets/fonts/icomoon.eot',
|
|
360
|
-
],
|
|
361
|
-
dest: 'fonts',
|
|
362
|
-
},
|
|
363
|
-
],
|
|
364
|
-
}),
|
|
365
|
-
].filter(Boolean),
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
// ============================================================================
|
|
369
|
-
// DUAL BUILD STRATEGY
|
|
370
|
-
// ============================================================================
|
|
371
|
-
const configs = [
|
|
372
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
373
|
-
// BUILD 1: NPM Package (dist/index.js)
|
|
374
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
375
|
-
// 📦 Sử dụng: import { ShowroomVisualizer } from '@clikvn/showroom-visualizer'
|
|
376
|
-
//
|
|
377
|
-
// ✅ Ưu điểm:
|
|
378
|
-
// - Dùng React version của host app (Next.js, React app)
|
|
379
|
-
// - Cho phép SWIZZLE components (share React instance)
|
|
380
|
-
// - File nhỏ (~1.8MB) vì không bundle React
|
|
381
|
-
//
|
|
382
|
-
// 📝 Use cases:
|
|
383
|
-
// - React/Next.js applications
|
|
384
|
-
// - Cần customize components qua custom layout overrides
|
|
385
|
-
// - Muốn kiểm soát React version
|
|
386
|
-
{
|
|
387
|
-
input: './src/index.ts', // ⭐ IMPORTANT: Do NOT bundle react / react-dom
|
|
388
|
-
external: ['react', 'react-dom', 'react/jsx-runtime'],
|
|
389
|
-
output: {
|
|
390
|
-
file: 'dist/index.js',
|
|
391
|
-
format: 'esm',
|
|
392
|
-
inlineDynamicImports: true,
|
|
393
|
-
},
|
|
394
|
-
...indexConfig, // ✅ External React dependencies
|
|
395
|
-
},
|
|
396
|
-
|
|
397
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
398
|
-
// BUILD 2: Web Component (dist/web.js)
|
|
399
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
400
|
-
// 🌐 Sử dụng: <script type="module" src="web.js"></script>
|
|
401
|
-
// hoặc: await import('web.js')
|
|
402
|
-
//
|
|
403
|
-
// ✅ Ưu điểm:
|
|
404
|
-
// - Standalone, không cần install dependencies
|
|
405
|
-
// - Hoạt động trong vanilla JS/HTML
|
|
406
|
-
// - Không cần build tools
|
|
407
|
-
//
|
|
408
|
-
// ❌ Hạn chế:
|
|
409
|
-
// - KHÔNG hỗ trợ custom layout overrides (khác React instance)
|
|
410
|
-
// - File lớn hơn (~2.0MB) vì bundle React
|
|
411
|
-
//
|
|
412
|
-
// 📝 Use cases:
|
|
413
|
-
// - Vanilla JS/HTML projects
|
|
414
|
-
// - Không cần customize UI
|
|
415
|
-
// - Quick integration
|
|
416
|
-
{
|
|
417
|
-
input: './src/web.ts',
|
|
418
|
-
output: {
|
|
419
|
-
file: 'dist/web.js',
|
|
420
|
-
format: 'esm',
|
|
421
|
-
inlineDynamicImports: true,
|
|
422
|
-
},
|
|
423
|
-
...browserConfig, // ✅ Bundle React version 19
|
|
424
|
-
},
|
|
425
|
-
];
|
|
426
|
-
|
|
427
|
-
export default configs;
|
|
1
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
2
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
+
import typescript from '@rollup/plugin-typescript';
|
|
4
|
+
import { terser } from 'rollup-plugin-terser';
|
|
5
|
+
import postcss from 'rollup-plugin-postcss';
|
|
6
|
+
import { babel } from '@rollup/plugin-babel';
|
|
7
|
+
import autoprefixer from 'autoprefixer';
|
|
8
|
+
import { typescriptPaths } from 'rollup-plugin-typescript-paths';
|
|
9
|
+
import json from '@rollup/plugin-json';
|
|
10
|
+
import { uglify } from 'rollup-plugin-uglify';
|
|
11
|
+
import replace from 'rollup-plugin-replace';
|
|
12
|
+
import tailwindcss from 'tailwindcss';
|
|
13
|
+
import copy from '@rollup-extras/plugin-copy';
|
|
14
|
+
|
|
15
|
+
const extensions = ['.ts', '.tsx', '.js'];
|
|
16
|
+
const isDev =
|
|
17
|
+
process.env.NODE_ENV === 'development' || process.env.ROLLUP_WATCH === 'true';
|
|
18
|
+
|
|
19
|
+
const indexConfig = {
|
|
20
|
+
context: 'this',
|
|
21
|
+
onwarn(warning, warn) {
|
|
22
|
+
// Bỏ qua warning về "use client" directive
|
|
23
|
+
if (
|
|
24
|
+
warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
|
|
25
|
+
warning.message.includes('"use client"')
|
|
26
|
+
) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// Hiển thị các warning khác
|
|
30
|
+
warn(warning);
|
|
31
|
+
},
|
|
32
|
+
plugins: [
|
|
33
|
+
resolve({
|
|
34
|
+
extensions,
|
|
35
|
+
browser: true,
|
|
36
|
+
dedupe: ['useTranslation', 'i18n', 'I18nextProvider'],
|
|
37
|
+
}),
|
|
38
|
+
commonjs(),
|
|
39
|
+
// Skip uglify in dev mode - tốn thời gian
|
|
40
|
+
!isDev && uglify(),
|
|
41
|
+
json(),
|
|
42
|
+
// Skip babel in dev mode - giảm thời gian compile
|
|
43
|
+
!isDev &&
|
|
44
|
+
babel({
|
|
45
|
+
babelHelpers: 'bundled',
|
|
46
|
+
exclude: 'node_modules/**',
|
|
47
|
+
extensions,
|
|
48
|
+
}),
|
|
49
|
+
copy({
|
|
50
|
+
targets: [
|
|
51
|
+
{
|
|
52
|
+
src: [
|
|
53
|
+
'src/assets/fonts/icomoon.woff',
|
|
54
|
+
'src/assets/fonts/icomoon.ttf',
|
|
55
|
+
'src/assets/fonts/icomoon.svg',
|
|
56
|
+
'src/assets/fonts/icomoon.eot',
|
|
57
|
+
],
|
|
58
|
+
dest: 'fonts',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
}),
|
|
62
|
+
replace({
|
|
63
|
+
'process.env.NODE_ENV': JSON.stringify(
|
|
64
|
+
isDev ? 'development' : 'production'
|
|
65
|
+
),
|
|
66
|
+
}),
|
|
67
|
+
postcss({
|
|
68
|
+
plugins: [autoprefixer(), tailwindcss()],
|
|
69
|
+
extract: false,
|
|
70
|
+
modules: false,
|
|
71
|
+
autoModules: false,
|
|
72
|
+
minimize: !isDev, // Skip minify CSS trong dev
|
|
73
|
+
inject: false,
|
|
74
|
+
}),
|
|
75
|
+
typescript({
|
|
76
|
+
sourceMap: isDev, // Source map chỉ trong dev
|
|
77
|
+
inlineSources: isDev,
|
|
78
|
+
}),
|
|
79
|
+
typescriptPaths({ preserveExtensions: true }),
|
|
80
|
+
// Skip terser trong dev - tốn rất nhiều thời gian
|
|
81
|
+
!isDev && terser({ output: { comments: false } }),
|
|
82
|
+
].filter(Boolean), // Remove false values
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const configs = [
|
|
86
|
+
{
|
|
87
|
+
input: './src/web.ts',
|
|
88
|
+
output: {
|
|
89
|
+
file: 'dist/web.js',
|
|
90
|
+
format: 'esm',
|
|
91
|
+
inlineDynamicImports: true,
|
|
92
|
+
},
|
|
93
|
+
...indexConfig,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
export default configs;
|