import path from 'path' import external from 'rollup-plugin-peer-deps-external' import resolve from '@rollup/plugin-node-resolve' import babel from 'rollup-plugin-babel' import json from '@rollup/plugin-json' import typescript from 'rollup-plugin-typescript2' import commonjs from 'rollup-plugin-commonjs' import tslint from 'rollup-plugin-tslint' import stylelint from 'rollup-plugin-stylelint' import postcss from 'rollup-plugin-postcss' import { terser } from 'rollup-plugin-terser' import pkg from './package.json' const paths = { input: path.join(__dirname, '/src/pages/view/NotebookPreview.tsx'), output: path.join(__dirname, '/lib') } const peerDependencies = ['react', 'react-dom', 'lodash', 'prop-types'] export default { input: paths.input, output: [ // 输出 commonjs 规范的代码 { file: path.join(paths.output, 'index.js'), format: 'cjs', name: pkg.name }, // 输出 es 规范的代码 { file: path.join(paths.output, 'index.esm.js'), format: 'es', name: pkg.name } ], plugins: [ json(), external(), stylelint(), tslint({ throwOnError: true, throwOnWarning: true, include: ['src/**/*.ts', 'src/**/*.tsx'], exclude: ['node_modules/**', '*.js', '*.scss', '*.css'] }), typescript(), babel({ exclude: 'node_modules/**' }), commonjs({ include: 'node_modules/**', namedExports: { 'node_modules/react-is/index.js': [ 'isFragment', 'ForwardRef', 'isValidElementType', 'isMemo', 'isElement' ] } }), // ascii(), postcss({ // Extract CSS to the same location where JS file is generated but with .css extension. extract: true, // Use named exports alongside default export. namedExports: true, // Minimize CSS, boolean or options for cssnano. minimize: true, // Enable sourceMap. sourceMap: false, // This plugin will process files ending with these extensions and the extensions supported by custom loaders. extensions: ['.less', '.css'], use: ['sass', ['less', { javascriptEnabled: true }]] }), terser(), resolve() ], external: peerDependencies }