1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-27 22:12:01 +08:00
trois/rollup.config.js

110 lines
2.5 KiB
JavaScript
Raw Normal View History

2021-02-21 21:10:11 +08:00
// import commonjs from '@rollup/plugin-commonjs';
2020-09-16 21:30:39 +08:00
import vue from 'rollup-plugin-vue';
import buble from '@rollup/plugin-buble';
import { terser } from "rollup-plugin-terser";
2021-02-26 05:55:44 +08:00
import replace from '@rollup/plugin-replace';
2020-09-16 21:30:39 +08:00
2020-10-04 06:49:05 +08:00
const input = 'src/export.js';
2020-09-17 05:54:14 +08:00
const external = [
'three',
'three/examples/jsm/controls/OrbitControls.js',
2021-02-21 21:10:11 +08:00
'three/examples/jsm/deprecated/Geometry.js',
2020-10-04 06:49:05 +08:00
'three/examples/jsm/loaders/GLTFLoader.js',
2020-09-17 05:54:14 +08:00
'three/examples/jsm/postprocessing/BokehPass.js',
2020-10-04 06:49:05 +08:00
'three/examples/jsm/postprocessing/EffectComposer.js',
'three/examples/jsm/postprocessing/FilmPass.js',
'three/examples/jsm/postprocessing/HalftonePass.js',
2020-09-17 05:54:14 +08:00
'three/examples/jsm/postprocessing/RenderPass.js',
2021-02-21 21:10:11 +08:00
'three/examples/jsm/postprocessing/Pass.js',
2020-10-04 06:49:05 +08:00
'three/examples/jsm/postprocessing/SAOPass.js',
2021-02-21 21:10:11 +08:00
'three/examples/jsm/postprocessing/SMAAPass.js',
'three/examples/jsm/postprocessing/ShaderPass.js',
2020-09-17 05:54:14 +08:00
'three/examples/jsm/postprocessing/UnrealBloomPass.js',
2021-02-21 21:10:11 +08:00
'three/examples/jsm/shaders/FXAAShader.js',
2020-10-04 06:49:05 +08:00
'gsap',
2020-09-17 05:54:14 +08:00
'vue',
];
2020-10-04 06:49:05 +08:00
2021-03-04 04:49:22 +08:00
const cdnReplaces = {
2021-02-26 05:55:44 +08:00
'from \'vue\'': 'from \'https://unpkg.com/vue@3.0.5/dist/vue.esm-browser.prod.js\'',
'from \'three\'': 'from \'https://unpkg.com/three@0.125.2/build/three.module.js\'',
'from \'three/examples': 'from \'https://unpkg.com/three@0.125.2/examples',
'from \'gsap\'': 'from \'https://unpkg.com/gsap@3.5.1/index.js\'',
delimiters: ['', ''],
};
2020-09-16 21:30:39 +08:00
const plugins = [
vue(),
buble({
2021-02-26 05:55:44 +08:00
transforms: { asyncAwait: false, forOf: false },
2020-09-17 16:57:13 +08:00
objectAssign: 'Object.assign',
2020-09-16 21:30:39 +08:00
}),
];
export default [
2021-02-26 05:55:44 +08:00
{
input,
external,
output: {
format: 'es',
exports: 'named',
file: 'build/trois.module.cdn.js',
sourcemap: true,
},
plugins: [
2021-03-04 04:49:22 +08:00
replace(cdnReplaces),
2021-02-26 05:55:44 +08:00
...plugins,
],
},
{
input,
external,
output: {
format: 'es',
exports: 'named',
file: 'build/trois.module.cdn.min.js',
sourcemap: true,
},
plugins: [
2021-03-04 04:49:22 +08:00
replace(cdnReplaces),
2021-02-26 05:55:44 +08:00
...plugins,
terser(),
],
},
2020-09-16 21:30:39 +08:00
{
input,
external,
output: {
format: 'es',
exports: 'named',
file: 'build/trois.module.js',
sourcemap: true,
},
plugins,
},
{
input,
external,
output: {
format: 'es',
exports: 'named',
file: 'build/trois.module.min.js',
sourcemap: true,
},
plugins: [
...plugins,
terser(),
],
},
2021-02-28 23:56:24 +08:00
{
input,
2021-03-04 04:49:22 +08:00
external,
2021-02-28 23:56:24 +08:00
output: {
format: 'cjs',
file: 'build/trois.js',
sourcemap: false,
},
2021-03-04 04:49:22 +08:00
plugins,
2021-02-28 23:56:24 +08:00
},
2020-09-16 21:30:39 +08:00
];