import json from 'rollup-plugin-json';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';

function glsl () {
	return {
		transform ( code, id ) {
			if ( !/\.glsl$/.test( id ) ) return;

			return 'export default ' + JSON.stringify(
				code
					.replace( /[ \t]*\/\/.*\n/g, '' )
					.replace( /[ \t]*\/\*[\s\S]*?\*\//g, '' )
					.replace( /\n{2,}/g, '\n' )
			) + ';';
		}
	};
}

export default {
	input: 'src/js/CV.js',
	output: {
		name: 'CV',
		file: 'build/CaveView/js/CaveView.js',
		format: 'umd'
	},
	plugins: [
		glsl(),
		json({
			// All JSON files will be parsed by default,
			// but you can also specifically include/exclude files
			include: [ 'node_modules/**', 'src/js/**' ],
			exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ],

			// for tree-shaking, properties will be declared as
			// variables, using either `var` or `const`
			preferConst: true, // Default: false

			// specify indentation for the generated default export —
			// defaults to '\t'
			indent: '  '
		}),
		nodeResolve({
			jsnext: true,
			main: true
		}),
		commonjs({
			// non-CommonJS modules will be ignored, but you can also
			// specifically include/exclude files
			include: 'node_modules/**',  // Default: undefined

			// search for files other than .js files (must already
			// be transpiled by a previous plugin!)
			extensions: [ '.js' ],  // Default: [ '.js' ]
			// if true then uses of `global` won't be dealt with by this plugin
			ignoreGlobal: false,  // Default: false
			// if false then skip sourceMap generation for CommonJS modules
			sourceMap: false,  // Default: true
		})
	]
};


@@ -428,16 +428,552 @@
 %0A%09%7D;%0A%7D%0A%0A
+function glslThree() %7B%0A%0A%09return %7B%0A%0A%09%09transform( code, id ) %7B%0A%0A%09%09%09if ( /%5C.glsl.js$/.test( id ) === false ) return;%0A%0A%09%09%09code = code.replace( /%5C/%5C* glsl %5C*%5C/%5C%60((.*%7C%5Cn%7C%5Cr%5Cn)*)%5C%60/, function ( match, p1 ) %7B%0A%0A%09%09%09%09return JSON.stringify(%0A%09%09%09%09%09p1%0A%09%09%09%09%09%09.trim()%0A%09%09%09%09%09%09.replace( /%5Cr/g, '' )%0A%09%09%09%09%09%09.replace( /%5B %5Ct%5D*%5C/%5C/.*%5Cn/g, '' ) // remove //%0A%09%09%09%09%09%09.replace( /%5B %5Ct%5D*%5C/%5C*%5B%5Cs%5CS%5D*?%5C*%5C//g, '' ) // remove /* */%0A%09%09%09%09%09%09.replace( /%5Cn%7B2,%7D/g, '%5Cn' ) // # %5Cn+ to %5Cn%0A%09%09%09%09);%0A%0A%09%09%09%7D );%0A%0A%09%09%09return %7B%0A%09%09%09%09code: code,%0A%09%09%09%09map: %7B mappings: '' %7D%0A%09%09%09%7D;%0A%0A%09%09%7D%0A%0A%09%7D;%0A%0A%7D%0A%0A
 export d
@@ -1113,16 +1113,31 @@
 glsl(),%0A
+%09%09glslThree(),%0A
 %09%09json(%7B

update to fix IE11 breakages