@mapvx/website-component 0.5.1 → 0.5.3

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 CHANGED
@@ -52,29 +52,95 @@ import '@mapvx/website-component/dist/browser/styles.css'
52
52
  ```jsx
53
53
  // In your main App.jsx or index.jsx
54
54
  import '@mapvx/website-component/dist/browser/main.js'
55
- import '@mapvx/website-component/dist/browser/styles.css'
56
55
 
57
56
  function App() {
58
57
  return <mapvx-website api-key="your-api-key-here" />
59
58
  }
60
59
  ```
61
60
 
61
+ ```css
62
+ /* In your main CSS file (e.g., index.css, App.css) */
63
+ @import '@mapvx/website-component/dist/browser/styles.css';
64
+ ```
65
+
62
66
  **Vue:**
63
67
 
64
68
  ```javascript
65
69
  // In your main.js
66
70
  import '@mapvx/website-component/dist/browser/main.js'
67
- import '@mapvx/website-component/dist/browser/styles.css'
71
+ ```
72
+
73
+ ```css
74
+ /* In your main CSS file (e.g., style.css, main.css) */
75
+ @import '@mapvx/website-component/dist/browser/styles.css';
68
76
  ```
69
77
 
70
78
  **Angular:**
71
79
 
80
+ #### Method 1: HTML Script Tags
81
+
82
+ Configure assets in `angular.json` and use script tags in `index.html`:
83
+
84
+ ```json
85
+ {
86
+ "assets": [
87
+ {
88
+ "glob": "**/*",
89
+ "input": "public"
90
+ },
91
+ {
92
+ "glob": "**/*",
93
+ "input": "src/assets",
94
+ "output": "assets"
95
+ },
96
+ {
97
+ "glob": "**/*",
98
+ "input": "node_modules/@mapvx/website-component/dist/browser",
99
+ "output": "website-component"
100
+ }
101
+ ]
102
+ }
103
+ ```
104
+
105
+ Then reference the files in your `index.html`:
106
+
107
+ ```html
108
+ <!-- Web Component Scripts -->
109
+ <script src="website-component/main.js" defer></script>
110
+
111
+ <!-- Web Component Styles -->
112
+ <link rel="stylesheet" href="website-component/styles.css" />
113
+ ```
114
+
115
+ **Why this configuration is needed:**
116
+
117
+ - Angular doesn't serve files from `node_modules` by default in development
118
+ - Without proper asset configuration, you'll get `SyntaxError: Unexpected token '<'` errors
119
+ - This ensures files are served as static assets with proper caching headers
120
+
121
+ #### Method 2: TypeScript Imports
122
+
123
+ Alternatively, you can import the files in your application:
124
+
72
125
  ```typescript
73
- // In your angular.json or import in main.ts
126
+ // In your main.ts - Import the JavaScript
74
127
  import '@mapvx/website-component/dist/browser/main.js'
75
- import '@mapvx/website-component/dist/browser/styles.css'
76
128
  ```
77
129
 
130
+ ```scss
131
+ /* In your styles.scss - Import the styles (Modern Sass) */
132
+ @use '@mapvx/website-component/dist/browser/styles.css';
133
+
134
+ /* Alternative for older Sass versions or CSS files */
135
+ @import '@mapvx/website-component/dist/browser/styles.css';
136
+ ```
137
+
138
+ **Important**: Choose ONE method only:
139
+
140
+ - ✅ **Method 1**: HTML script tags + assets configuration
141
+ - ✅ **Method 2**: TypeScript imports + SCSS imports
142
+ - ❌ **Don't use both**: This can cause duplicate loading and conflicts
143
+
78
144
  ### Helper Package (SSR Support)
79
145
 
80
146
  For Server-Side Rendering (SSR) applications that need to preload initial data on the server:
@@ -433,6 +499,36 @@ function App() {
433
499
  - The web component will automatically pick up these custom colors
434
500
  - Use valid CSS color values (hex, rgb, hsl, etc.)
435
501
 
502
+ ## 🔧 Troubleshooting
503
+
504
+ ### Common Issues
505
+
506
+ #### `SyntaxError: Unexpected token '<'` in Angular
507
+
508
+ **Problem**: Angular returns HTML instead of JavaScript files from `node_modules`.
509
+
510
+ **Solution**: Configure assets in `angular.json` as shown in the Angular Configuration section above.
511
+
512
+ #### Slow Loading (>10 seconds)
513
+
514
+ **Problem**: Large bundle size or incorrect asset serving.
515
+
516
+ **Solutions**:
517
+
518
+ - Use the recommended Angular assets configuration
519
+ - Ensure files are served as static assets, not through routing
520
+ - Check network tab in DevTools for 404 errors
521
+
522
+ #### Web Component Not Loading
523
+
524
+ **Problem**: Scripts not loading or component not registering.
525
+
526
+ **Solutions**:
527
+
528
+ - Verify file paths are correct
529
+ - Check browser console for errors
530
+ - Ensure `defer` attribute is used for script tags
531
+
436
532
  ## 🏠 Homepage
437
533
 
438
534
  Visit [MapVX](https://mapvx.com) for more information.