earthsdk3-assets 3.0.22 → 3.0.23
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/package.json +1 -1
- package/src/plugins/rspack.cjs +25 -24
- package/src/plugins/vite.js +1 -1
- package/src/plugins/webpack.cjs +25 -24
package/package.json
CHANGED
package/src/plugins/rspack.cjs
CHANGED
|
@@ -56,7 +56,7 @@ class EarthsdkAssetsRspackPlugin {
|
|
|
56
56
|
tagName: 'script',
|
|
57
57
|
voidTag: false,
|
|
58
58
|
attributes: {
|
|
59
|
-
src: '
|
|
59
|
+
src: './js/earthsdk3-assets/earthsdk3-assets.js'
|
|
60
60
|
},
|
|
61
61
|
meta: { plugin: 'earthsdk-assets' }
|
|
62
62
|
});
|
|
@@ -72,33 +72,34 @@ class EarthsdkAssetsRspackPlugin {
|
|
|
72
72
|
|
|
73
73
|
compiler.hooks.afterEnvironment.tap('EarthsdkAssetsRspackPlugin', () => {
|
|
74
74
|
const devServer = compiler.options.devServer;
|
|
75
|
-
const outputPath = compiler.options.output.path || 'dist';
|
|
76
75
|
if (devServer) {
|
|
77
76
|
const originalSetup = devServer.setupMiddlewares;
|
|
78
77
|
devServer.setupMiddlewares = (middlewares, devServer) => {
|
|
79
|
-
devServer.app.use('/js', (req, res, next) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const mimeTypes = {
|
|
88
|
-
js: 'application/javascript',
|
|
89
|
-
json: 'application/json',
|
|
90
|
-
png: 'image/png',
|
|
91
|
-
jpg: 'image/jpeg',
|
|
92
|
-
jpeg: 'image/jpeg',
|
|
93
|
-
webp: 'image/webp',
|
|
94
|
-
glb: 'model/gltf-binary',
|
|
95
|
-
bin: 'application/octet-stream'
|
|
96
|
-
};
|
|
97
|
-
res.setHeader('Content-Type', mimeTypes[ext] || 'application/octet-stream');
|
|
98
|
-
fs.createReadStream(filePath).pipe(res);
|
|
99
|
-
} catch (err) {
|
|
100
|
-
next(err);
|
|
78
|
+
devServer.app.use('/js/earthsdk3-assets', (req, res, next) => {
|
|
79
|
+
const urlPath = decodeURIComponent(req.url);
|
|
80
|
+
const filePath = urlPath === '/'
|
|
81
|
+
? path.join(ROOT_DIR, 'earthsdk3-assets.js')
|
|
82
|
+
: path.join(ROOT_DIR, urlPath.slice(1));
|
|
83
|
+
|
|
84
|
+
if (!fs.existsSync(filePath)) {
|
|
85
|
+
return next();
|
|
101
86
|
}
|
|
87
|
+
|
|
88
|
+
const ext = path.extname(filePath).slice(1).toLowerCase();
|
|
89
|
+
const mimeTypes = {
|
|
90
|
+
js: 'application/javascript',
|
|
91
|
+
json: 'application/json',
|
|
92
|
+
png: 'image/png',
|
|
93
|
+
jpg: 'image/jpeg',
|
|
94
|
+
jpeg: 'image/jpeg',
|
|
95
|
+
webp: 'image/webp',
|
|
96
|
+
glb: 'model/gltf-binary',
|
|
97
|
+
bin: 'application/octet-stream'
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
res.setHeader('Content-Type', mimeTypes[ext] || 'application/octet-stream');
|
|
101
|
+
res.setHeader('Cache-Control', 'max-age=3600');
|
|
102
|
+
fs.createReadStream(filePath).pipe(res);
|
|
102
103
|
});
|
|
103
104
|
|
|
104
105
|
if (originalSetup) {
|
package/src/plugins/vite.js
CHANGED
package/src/plugins/webpack.cjs
CHANGED
|
@@ -46,7 +46,7 @@ class EarthsdkAssetsWebpackPlugin {
|
|
|
46
46
|
tagName: 'script',
|
|
47
47
|
voidTag: false,
|
|
48
48
|
attributes: {
|
|
49
|
-
src: '
|
|
49
|
+
src: './js/earthsdk3-assets/earthsdk3-assets.js'
|
|
50
50
|
},
|
|
51
51
|
meta: { plugin: 'earthsdk-assets' }
|
|
52
52
|
});
|
|
@@ -62,33 +62,34 @@ class EarthsdkAssetsWebpackPlugin {
|
|
|
62
62
|
|
|
63
63
|
compiler.hooks.afterEnvironment.tap('EarthsdkAssetsWebpackPlugin', () => {
|
|
64
64
|
const devServer = compiler.options.devServer;
|
|
65
|
-
const outputPath = compiler.options.output.path || 'dist';
|
|
66
65
|
if (devServer) {
|
|
67
66
|
const originalSetup = devServer.setupMiddlewares;
|
|
68
67
|
devServer.setupMiddlewares = (middlewares, devServer) => {
|
|
69
|
-
devServer.app.use('/js', (req, res, next) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const mimeTypes = {
|
|
78
|
-
js: 'application/javascript',
|
|
79
|
-
json: 'application/json',
|
|
80
|
-
png: 'image/png',
|
|
81
|
-
jpg: 'image/jpeg',
|
|
82
|
-
jpeg: 'image/jpeg',
|
|
83
|
-
webp: 'image/webp',
|
|
84
|
-
glb: 'model/gltf-binary',
|
|
85
|
-
bin: 'application/octet-stream'
|
|
86
|
-
};
|
|
87
|
-
res.setHeader('Content-Type', mimeTypes[ext] || 'application/octet-stream');
|
|
88
|
-
fs.createReadStream(filePath).pipe(res);
|
|
89
|
-
} catch (err) {
|
|
90
|
-
next(err);
|
|
68
|
+
devServer.app.use('/js/earthsdk3-assets', (req, res, next) => {
|
|
69
|
+
const urlPath = decodeURIComponent(req.url);
|
|
70
|
+
const filePath = urlPath === '/'
|
|
71
|
+
? path.join(ROOT_DIR, 'earthsdk3-assets.js')
|
|
72
|
+
: path.join(ROOT_DIR, urlPath.slice(1));
|
|
73
|
+
|
|
74
|
+
if (!fs.existsSync(filePath)) {
|
|
75
|
+
return next();
|
|
91
76
|
}
|
|
77
|
+
|
|
78
|
+
const ext = path.extname(filePath).slice(1).toLowerCase();
|
|
79
|
+
const mimeTypes = {
|
|
80
|
+
js: 'application/javascript',
|
|
81
|
+
json: 'application/json',
|
|
82
|
+
png: 'image/png',
|
|
83
|
+
jpg: 'image/jpeg',
|
|
84
|
+
jpeg: 'image/jpeg',
|
|
85
|
+
webp: 'image/webp',
|
|
86
|
+
glb: 'model/gltf-binary',
|
|
87
|
+
bin: 'application/octet-stream'
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
res.setHeader('Content-Type', mimeTypes[ext] || 'application/octet-stream');
|
|
91
|
+
res.setHeader('Cache-Control', 'max-age=3600');
|
|
92
|
+
fs.createReadStream(filePath).pipe(res);
|
|
92
93
|
});
|
|
93
94
|
|
|
94
95
|
if (originalSetup) {
|