| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- import MagicString from 'magic-string';
- function glsl() {
- return {
- transform( code, id ) {
- if ( /\.glsl.js$/.test( id ) === false ) return;
- code = new MagicString( code );
- code.replace( /\/\* glsl \*\/\`(.*?)\`/sg, function ( match, p1 ) {
- return JSON.stringify(
- p1
- .trim()
- .replace( /\r/g, '' )
- .replace( /[ \t]*\/\/.*\n/g, '' ) // remove //
- .replace( /[ \t]*\/\*[\s\S]*?\*\//g, '' ) // remove /* */
- .replace( /\n{2,}/g, '\n' ) // # \n+ to \n
- );
- } );
- return {
- code: code.toString(),
- map: code.generateMap()
- };
- }
- };
- }
- function header() {
- return {
- renderChunk( code ) {
- code = new MagicString( code );
- code.prepend( `/**
- * @license
- * Copyright 2010-2026 Three.js Authors
- * SPDX-License-Identifier: MIT
- */\n` );
- return {
- code: code.toString(),
- map: code.generateMap()
- };
- }
- };
- }
- /**
- * @type {Array<import('rollup').RollupOptions>}
- */
- const builds = [
- {
- input: {
- 'three.core.js': 'src/Three.Core.js',
- 'three.webgpu.nodes.js': 'src/Three.WebGPU.Nodes.js',
- },
- plugins: [
- glsl(),
- header()
- ],
- preserveEntrySignatures: 'allow-extension',
- output: [
- {
- format: 'esm',
- dir: 'build',
- minifyInternalExports: false,
- entryFileNames: '[name]',
- }
- ]
- },
- {
- input: {
- 'three.core.js': 'src/Three.Core.js',
- 'three.module.js': 'src/Three.js',
- 'three.webgpu.js': 'src/Three.WebGPU.js',
- },
- plugins: [
- glsl(),
- header()
- ],
- preserveEntrySignatures: 'allow-extension',
- output: [
- {
- format: 'esm',
- dir: 'build',
- minifyInternalExports: false,
- entryFileNames: '[name]',
- }
- ]
- },
- {
- input: {
- 'three.tsl.js': 'src/Three.TSL.js',
- },
- plugins: [
- header()
- ],
- preserveEntrySignatures: 'allow-extension',
- output: [
- {
- format: 'esm',
- dir: 'build',
- minifyInternalExports: false,
- entryFileNames: '[name]',
- }
- ],
- external: [ 'three/webgpu' ]
- }
- ];
- export default builds;
|