-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.js
124 lines (117 loc) · 3.05 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* @Author: ATSLotus/时桐
* @Date: 2022-02-24 22:05:19
* @LastEditors: ATSLotus/时桐
* @LastEditTime: 2022-11-18 20:04:04
* @Description:
* @FilePath: /ezpsy/rollup.config.js
*/
import typescript from 'rollup-plugin-typescript2';
import babel from '@rollup/plugin-babel';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import wasm from '@rollup/plugin-wasm';
import replace from '@rollup/plugin-replace'
import { terser } from "rollup-plugin-terser";
const postcss = require('rollup-plugin-postcss');
// const sass = require('node-sass');
import simplevars from 'postcss-simple-vars';
import nested from 'postcss-nested';
import cssnext from 'postcss-cssnext';
import cssnano from 'cssnano';
// import css from "rollup-plugin-import-css"
// const resolveFile = function(filePath) {
// let p = path.join(__dirname, '..', filePath)
// console.dir(p)
// return p
// }
// const isProductionEnv = process.env.NODE_ENV === 'production'
// const processSass = function(context, payload) {
// return new Promise(( resolve, reject ) => {
// sass.render({
// file: context
// }, function(err, result) {
// if( !err ) {
// resolve(result);
// } else {
// reject(err)
// }
// });
// })
// }
module.exports = [
{
input: './src/index.ts', //输入文件
output:[ //输出文件
{
file: 'dist/ezpsy.js',
format: 'iife',
name: 'ezpsy'
},
{
file: 'dist/index.js',
format: "esm",
name: "ezpsy"
},
],
context: 'that',
plugins:[
wasm({
sync: [
'static/singrat_bg.wasm',
'static/singrat_bg_0.wasm'
]
}),
typescript(), // 默认从 tsconfig加载数据
// nodeResolve(),
// postcss({
// extract: true,
// minimize: isProductionEnv,
// extensions:['css', 'scss'],
// process: processSass,
// }),
postcss({
plugins: [
simplevars(),
nested(),
cssnext({ warnForDuplicates: false, }),
cssnano(),
],
extensions: [ '.css','.scss' ],
}),
nodeResolve({
jsnext: true,
main: true,
browser: true,
}),
commonjs(),
// processSass(),
// scss({ sync: [
// "sweetalert2/src/sweetalert2.scss",
// "src/Dialogue/dialogue.scss"
// ] }),
// replace({
// "_loadWasmModule(1,":"_loadWasmModule(0,",
// delimiters: ['','']
// }),
// eslint({
// exclude: [
// 'src/Style/**',
// ]
// }),
babel({
"presets": ['@babel/preset-env'],
exclude: 'node_modules/**' // 只编译我们的源代码
}),
replace({
"_loadWasmModule(1,":"_loadWasmModule(0,",
delimiters: ['',''],
"preventAssignment": true
}),
// terser()
// replace({
// ENV: JSON.stringify(process.env.NODE_ENV || 'development'),
// })
],
},
]