diff --git a/package.json b/package.json index 19197b3c7a1186..dd9b4af6ccd8e1 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,8 @@ "test-e2e": "node test/e2e/puppeteer.js", "test-e2e-cov": "node test/e2e/check-coverage.js", "test-treeshake": "rollup -c test/rollup.treeshake.config.js", - "make-screenshot": "node test/e2e/puppeteer.js --make" + "make-screenshot": "node test/e2e/puppeteer.js --make", + "prepublishOnly": "node utils/prepublish.js" }, "keywords": [ "three", diff --git a/utils/prepublish.js b/utils/prepublish.js new file mode 100644 index 00000000000000..caeae3018a2eda --- /dev/null +++ b/utils/prepublish.js @@ -0,0 +1,12 @@ +const fs = require( 'fs' ); +const path = require( 'path' ); +const glob = require( 'glob' ); + +const paths = glob.sync( path.resolve( __dirname, '../examples/jsm/**/*.js' ) ); +paths.forEach( p => { + + const content = fs.readFileSync( p, { encoding: 'utf8' } ); + const bareContent = content.replace( /(\.\.\/){2,}build\/three.module.js/g, 'three' ); + fs.writeFileSync( p, bareContent, { encoding: 'utf8' } ); + +} );