1 Star 4 Fork 2

维李设论/vue-network-topology

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rollup.config.js 2.56 KB
一键复制 编辑 原始数据 按行查看 历史
we452366 提交于 2023-06-20 11:25 . chore: 版本0.1.0打包
import babel from "rollup-plugin-babel";
// CommonJS
import commonjs from "rollup-plugin-commonjs";
// 预处理器
import postcss from "rollup-plugin-postcss";
import autoprefixer from "autoprefixer";
import cssnano from "cssnano";
// 识别.vue文件
import PluginVue from "rollup-plugin-vue";
// 压缩使用
import {
terser
} from "rollup-plugin-terser";
// 热更新
// 提供web服务器
import serve from 'rollup-plugin-serve';
// 监听包
import livereload from 'rollup-plugin-livereload';
const PACKAGE_NAME = `vue-network-topology`;
const plugins = [
PluginVue(),
babel({
exclude: "node_modules/**",
runtimeHelpers: true,
}),
commonjs(),
postcss({
plugins: [
autoprefixer(),
cssnano()
],
})
];
if(process.env.NODE_ENV == 'dev') {
plugins.push(
serve({
contentBase: '', // 服务器启动的文件夹,默认是项目根目录,需要在该文件下创建index.html
port: 8020 // 端口号,默认10001
}),
livereload('dist'), //watch dist目录,当目录中的文件发生变化时,刷新页面
)
} else {
plugins.push(removeConsole())
}
const sourcemap = process.env.NODE_ENV == 'dev' ? 'inline' : false
// 去除console插件
function removeConsole() {
return {
name: "remove-console",
transform(code, id) {
const Reg = /console\.log\(.*\)/gi;
return code.replace(Reg, "");
},
};
}
export default {
input: "./packages/index.js",
output: [
{
// es6模块
file: `./dist/${PACKAGE_NAME}.esm.js`,
format: "es",
sourcemap
},
{
// es6模块 minify
file: `./dist/${PACKAGE_NAME}.esm.min.js`,
format: "es",
plugins: [
terser()
]
},
{
// commonjs模块
file: `./dist/${PACKAGE_NAME}.cjs.js`,
format: "cjs",
sourcemap
},
{
// commonjs模块 minify
file: `./dist/${PACKAGE_NAME}.cjs.min.js`,
format: "cjs",
plugins: [
terser()
]
},
{
// global模块
file: `./dist/${PACKAGE_NAME}.global.js`,
format: "iife",
name: 'VueNetworkTopology',
sourcemap,
// ant-design-vue里用的是antd
globals: {
"ant-design-vue": "antd"
}
},
{
// global模块 minify
file: `./dist/${PACKAGE_NAME}.global.min.js`,
format: "iife",
name: 'VueNetworkTopology',
plugins: [
terser()
],
// ant-design-vue里用的是antd
globals: {
"ant-design-vue": "antd"
}
}
],
plugins,
external: [
'vue',
"ant-design-vue"
]
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/VLeeDesignTheory/vue-network-topology.git
git@gitee.com:VLeeDesignTheory/vue-network-topology.git
VLeeDesignTheory
vue-network-topology
vue-network-topology
master

搜索帮助