-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
62 lines (55 loc) · 1.62 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
/*
* @Author: sunji [email protected]
* @Date: 2022-06-17 13:43:13
* @LastEditors: sunji [email protected]
* @LastEditTime: 2022-08-12 17:00:39
* @FilePath: \vue-ue-sdk\rollup.config.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import babel from 'rollup-plugin-babel'
import resolve from "@rollup/plugin-node-resolve";
import VuePlugin from 'rollup-plugin-vue'
import unassert from 'rollup-plugin-unassert';
import commonjs from "@rollup/plugin-commonjs"
import css from 'rollup-plugin-css-only' // 提取css,压缩能力不行
import CleanCSS from 'clean-css' // 压缩css
import {
writeFileSync
} from 'fs' // 写文件
import {
terser
} from 'rollup-plugin-terser'
const extensions = [".js"];
export default {
input: './src/index.js',
output: {
file: './dist/bundle.esm.js',
format: 'esm', //若打包commonjs
assetFileNames: "[name]-[hash][extname]"
},
// external: ["vue", "@vue/compiler-sfc"],
plugins: [
resolve(),
babel({
exclude: "node_modules/**",
extensions,
runtimeHelpers: true,
}),
commonjs(),
VuePlugin({
css: false
}),
css({
output(style) {
// 压缩 css 写入 dist/vue-rollup-component-template.css
writeFileSync('./dist/index.css', new CleanCSS().minify(style).styles)
}
}),
// css: false 将<style>块转换为导入语句,rollup-plugin-css-only可以提取.vue文件中的样式
unassert(),
// terser()
],
treeshake: {
moduleSideEffects: false,
}
}