forked from xaboy/form-create-designer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
92 lines (90 loc) · 2.8 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
/*
* @Author : djkloop
* @Date : 2021-04-04 23:18:00
* @LastEditors : djkloop
* @LastEditTime : 2021-04-05 12:44:31
* @Description : 头部注释
* @FilePath : /rollup.config.js
*/
const {join} = require('path');
import colors from 'chalk';
import {babel} from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import vuePlugin from 'rollup-plugin-vue';
import postcss from 'rollup-plugin-postcss';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import {visualizer} from 'rollup-plugin-visualizer';
import externals from 'rollup-plugin-node-externals';
import buble from '@rollup/plugin-buble';
import formCreateNodeResolve from './build/plugins/form-create-rollup-reslove-plugins/node-resolve';
import {not_externals, isExternal} from './build/utils/isExternal';
import {cssUrl} from '@sixian/css-url';
const OutputOptions = require('./build/output');
const cwd = __dirname;
const globals = {
vue: 'Vue',
ELEMENT: 'element-ui'
};
module.exports = {
input: join(cwd, '/src/index.js'),
onwarn: (warning) => {
if (typeof warning === 'string') {
return colors.yellow('warning');
}
const code = (warning.code || '').toLowerCase();
if (code === 'mixed_exports' || code === 'missing_global_name') {
return;
}
let message = warning.message;
console.log(`${colors.yellow(`${code}`)}${colors.dim(':')} ${message}`);
},
output: OutputOptions(),
external:Object.keys(globals || {}).filter(
v => !/^[\.\/]/.test(v)
),
plugins: [
vuePlugin({
css: false
}),
postcss({
minimize: true,
extract: false,
plugins: [
cssUrl({
imgExtensions : /\.(png|jpg|jpeg|gif|svg)$/,
fontExtensions : /\.(ttf|woff|woff2|eot)$/,
limit : 8192,
hash : false,
slash : false
}),
]
}),
externals({
devDeps: false
}),
formCreateNodeResolve(),
nodeResolve({
extensions: ['.js', '.json', '.jsx', '.ts', '.tsx'],
preferBuiltins: true,
jsnext: true,
module: true
}),
commonjs({
ignore: (name) => {
return isExternal(not_externals, name);
}
}),
babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**',
extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.vue'],
}),
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify('production'),
}),
buble(),
visualizer()
]
};