@monogrid/gltf-loader
Advanced tools
Comparing version 0.0.3 to 0.1.0
16
index.js
const path = require('path'); | ||
const loaderUtils = require('loader-utils') | ||
function resolveDependency(loader, context, chunkPath) { | ||
@@ -13,2 +15,4 @@ return new Promise((resolve, reject) => { | ||
module.exports = function(source) { | ||
let options = Object.assign({}, loaderUtils.getOptions(this)) | ||
if (this.cacheable) this.cacheable(); | ||
@@ -53,3 +57,7 @@ const callback = this.async(); | ||
// add a require statement to result | ||
result = result.concat("var asset" + i + " = require('./" + trimmedMatches[i] + "');\n"); | ||
if (options.moduleExport === 'CommonJs') { | ||
result = result.concat("var asset" + i + " = require('./" + trimmedMatches[i] + "');\n"); | ||
} else { | ||
result = result.concat("import asset" + i + " from './" + trimmedMatches[i] + "';\n"); | ||
} | ||
// replace require in gltfString | ||
@@ -59,3 +67,7 @@ gltfString = gltfString.replace( new RegExp(trimmedMatches[i], 'g'), "' + asset" + i + " + '" ) | ||
// add export gltf string | ||
result = result.concat('module.exports = \'' + gltfString + '\';\n') | ||
if (options.moduleExport === 'CommonJs') { | ||
result = result.concat('module.exports = \'' + gltfString + '\';\n') | ||
} else { | ||
result = result.concat('export default \'' + gltfString + '\';\n') | ||
} | ||
// callback | ||
@@ -62,0 +74,0 @@ callback(null, result) |
{ | ||
"name": "@monogrid/gltf-loader", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "A webpack loader for .gltf files, should automatically bundles all referenced files.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,4 +0,4 @@ | ||
# Webpack GLTF loader 2 | ||
# Webpack GLTF loader | ||
A webpack loader for ``.gltf`` files, should automatically bundles all referenced files. | ||
> A webpack loader for ``.gltf`` files, should automatically bundles all referenced files. | ||
@@ -11,4 +11,16 @@ Based on the work by [Magnus Bergman](https://github.com/magnus-bergman) but rewritten almost from scratch. | ||
**WARNING: this is pretty much untested and alpha version, contrubutions appreciated** | ||
**WARNING: this is pretty much untested and alpha version, contributions appreciated** | ||
## Installation | ||
```bash | ||
npm install --save-dev @monogrid/gltf-loader | ||
``` | ||
or | ||
```bash | ||
yarn add --dev @monogrid/gltf-loader | ||
``` | ||
## Webpack configuration | ||
@@ -37,3 +49,3 @@ | ||
test: /\.(gltf)$/, | ||
loader: 'gltf-loader-2' | ||
loader: '@monogrid/gltf-loader' | ||
}, | ||
@@ -69,1 +81,32 @@ { | ||
``` | ||
## CHANGELOG | ||
### 0.1.0 | ||
* dropped support for nodejs8.x | ||
* loader now uses es6 exports, can be forced to export a CommonJS module with "moduleExport" option set to "CommonJS" | ||
## LICENSE | ||
Copyright (c) 2020, MONOGRID S.R.L. | ||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7855
66
110