{"size": 1211, "ext": "js", "max_stars_repo_path": "rollup.config.js", "max_stars_repo_name": "vvyuan/vue-cf", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "rollup.config.js", "max_issues_repo_name": "vvyuan/vue-cf", "max_issues_repo_issues_event_min_datetime": "2021-05-11T06:06:20.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-11T06:06:20.000Z", "max_forks_repo_path": "rollup.config.js", "max_forks_repo_name": "vvyuan/vue-cf", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 24.22, "max_line_length": 120, "alphanum_fraction": 0.5887696119}
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import vue from 'rollup-plugin-vue2';
import less from 'rollup-plugin-less';
import babel from 'rollup-plugin-babel';
import fs from 'fs';

const cssTarget = 'index.css';
// 删除已创建的css文件
if(fs.existsSync(cssTarget)) {
  fs.unlinkSync(cssTarget);
}
export default {
  input: 'src/index.ts',
  // input: 'src/components/CFCommonForm.vue',
  output: {
    file: 'index.js',
    name: 'index.js',
    sourcemap: true,
    // format: 'umd',
  },
  plugins: [
    // typescript({exclude: ['.vue']}),
    vue(),
    less({
      output: function (css) {
        // 写入index.css
        fs.appendFileSync(cssTarget, css, 'utf-8');
        return ''
      }
    }),
    typescript(),
    resolve({ extensions: ['.js', '.ts', '.vue']}), // so Rollup can find `ms`
    // commonjs({ extensions: ['.js', '.ts'], exclude: ['.vue', '.css']}), // so Rollup can convert `ms` to an ES module
    babel({
      exclude: 'node_modules/**'
    }),
  ],
  // 指出应将哪些模块视为外部模块
  external: [
    'vue',
    'vue-router',
    'ant-design-vue',
    'moment',
    'uuid',
    'md5',
  ]
};
