Browse Source

Add an npm "script" named "build-test" to build Three.Unit.js file, using new file rollup.unit.config.js, to three.unit.js under test/unit folder

Tristan VALCKE 8 years ago
parent
commit
8f36e0aa3e
2 changed files with 41 additions and 0 deletions
  1. 1 0
      package.json
  2. 40 0
      rollup.unit.config.js

+ 1 - 0
package.json

@@ -27,6 +27,7 @@
   },
   "scripts": {
     "build": "rollup -c",
+    "build-test": "rollup -c rollup.test.config.js",
     "build-uglify": "rollup -c && uglifyjs build/three.js -cm --preamble \"// threejs.org/license\" > build/three.min.js",
     "build-closure": "rollup -c && java -jar utils/build/compiler/closure-compiler-v20160713.jar --warning_level=VERBOSE --jscomp_off=globalThis --jscomp_off=checkTypes --externs utils/build/externs.js --language_in=ECMASCRIPT5_STRICT --js build/three.js --js_output_file build/three.min.js",
     "dev": "rollup -c -w",

+ 40 - 0
rollup.unit.config.js

@@ -0,0 +1,40 @@
+function glsl() {
+
+	return {
+
+		transform( code, id ) {
+
+			if ( /\.glsl$/.test( id ) === false ) return;
+
+			var transformedCode = 'export default ' + JSON.stringify(
+				code
+					.replace( /[ \t]*\/\/.*\n/g, '' )
+					.replace( /[ \t]*\/\*[\s\S]*?\*\//g, '' )
+					.replace( /\n{2,}/g, '\n' )
+			) + ';';
+			return {
+				code: transformedCode,
+				map: { mappings: '' }
+			};
+
+		}
+
+	};
+
+}
+
+export default {
+	entry: 'src/Three.Unit.js',
+	indent: '\t',
+	plugins: [
+		glsl()
+	],
+	// sourceMap: true,
+	targets: [
+		{
+			format: 'umd',
+			moduleName: 'THREE',
+			dest: 'test/unit/three.unit.js'
+		}
+	]
+};