diff --git a/rollup.config.js b/rollup.config.js index 9e1c2e692e638ef48a633f70f2fc745da413ee35..a570ed84ca89c4de23aa4b6a887b2314592958ae 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -24,66 +24,21 @@ function glsl() { } export default { - - entry: (function () { - - var env = process.env.BUILD; - - if( env === 'production' ) { - - return 'src/Three.js'; - - } else if( env === 'test' ){ - - return 'test/Three.Unit.js'; - - } else { - - console.error("Invalid BUILD environment variable: " + env); - return null; - - } - - })(), + entry: 'src/Three.js', indent: '\t', plugins: [ glsl() ], // sourceMap: true, - targets: (function () { - - var env = process.env.BUILD; - - if( env === 'production' ) { - - return [ - { - format: 'umd', - moduleName: 'THREE', - dest: 'build/three.js' - }, - { - format: 'es', - dest: 'build/three.module.js' - } - ]; - - } else if( env === 'test' ){ - - return [ - { - format: 'umd', - moduleName: 'THREE', - dest: 'test/unit/three.unit.js' - } - ]; - - } else { - - console.error("Invalid BUILD environment variable: " + env); - return null; - + targets: [ + { + format: 'umd', + moduleName: 'THREE', + dest: 'build/three.js' + }, + { + format: 'es', + dest: 'build/three.module.js' } - - })() + ] }; diff --git a/rollup.unit.config.js b/rollup.unit.config.js new file mode 100644 index 0000000000000000000000000000000000000000..07e59209064fa292306045570d66b812bcdd8311 --- /dev/null +++ b/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: 'test/Three.Unit.js', + indent: '\t', + plugins: [ + glsl() + ], + // sourceMap: true, + targets: [ + { + format: 'umd', + moduleName: 'THREE', + dest: 'test/unit/three.unit.js' + } + ] +};