Skip to content

Commit 53e3b99

Browse files
authored
Examples: Convert jsm examples to use bare three import only before publish (#21654)
* Add prepublish script * Add prepublish only script
1 parent 6df08ab commit 53e3b99

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
"test-e2e": "node test/e2e/puppeteer.js",
7474
"test-e2e-cov": "node test/e2e/check-coverage.js",
7575
"test-treeshake": "rollup -c test/rollup.treeshake.config.js",
76-
"make-screenshot": "node test/e2e/puppeteer.js --make"
76+
"make-screenshot": "node test/e2e/puppeteer.js --make",
77+
"prepublishOnly": "node utils/prepublish.js"
7778
},
7879
"keywords": [
7980
"three",

utils/prepublish.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const fs = require( 'fs' );
2+
const path = require( 'path' );
3+
const glob = require( 'glob' );
4+
5+
const paths = glob.sync( path.resolve( __dirname, '../examples/jsm/**/*.js' ) );
6+
paths.forEach( p => {
7+
8+
const content = fs.readFileSync( p, { encoding: 'utf8' } );
9+
const bareContent = content.replace( /(\.\.\/){2,}build\/three.module.js/g, 'three' );
10+
fs.writeFileSync( p, bareContent, { encoding: 'utf8' } );
11+
12+
} );

0 commit comments

Comments
 (0)