whoami1337 1 年之前
父节点
当前提交
af708b516c
共有 10 个文件被更改,包括 733 次插入22 次删除
  1. 2 1
      .eslintrc.cjs
  2. 16 1
      package.json
  3. 二进制
      qf-ui-v0.0.0.tgz
  4. 37 0
      rollup.config.js
  5. 1 0
      src/index.ts
  6. 1 1
      src/main.tsx
  7. 2 1
      src/stories/Button.tsx
  8. 0 2
      src/stories/Header.tsx
  9. 5 3
      tsconfig.json
  10. 669 13
      yarn.lock

+ 2 - 1
.eslintrc.cjs

@@ -11,6 +11,7 @@ module.exports = {
   },
   plugins: ['react-refresh'],
   rules: {
-    'react-refresh/only-export-components': 'warn'
+    'react-refresh/only-export-components': 'warn',
+    
   }
 };

+ 16 - 1
package.json

@@ -9,13 +9,18 @@
     "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
     "preview": "vite preview",
     "storybook": "storybook dev -p 6006",
-    "build-storybook": "storybook build"
+    "build-storybook": "storybook build",
+    "build-library": "rollup -c"
   },
   "dependencies": {
     "react": "^18.2.0",
     "react-dom": "^18.2.0"
   },
   "devDependencies": {
+    "@babel/core": "^7.21.8",
+    "@babel/preset-env": "^7.21.5",
+    "@babel/preset-react": "^7.18.6",
+    "@rollup/plugin-babel": "^6.0.3",
     "@storybook/addon-essentials": "^7.0.15",
     "@storybook/addon-interactions": "^7.0.15",
     "@storybook/addon-links": "^7.0.15",
@@ -33,6 +38,16 @@
     "eslint-plugin-react-refresh": "^0.3.4",
     "eslint-plugin-storybook": "^0.6.12",
     "prop-types": "^15.8.1",
+    "rollup": "^3.23.0",
+    "rollup-plugin-babel": "^4.4.0",
+    "rollup-plugin-commonjs": "^10.1.0",
+    "rollup-plugin-node-resolve": "^5.2.0",
+    "rollup-plugin-peer-deps-external": "^2.2.4",
+    "rollup-plugin-postcss": "^4.0.2",
+    "rollup-plugin-sass": "^1.12.19",
+    "rollup-plugin-terser": "^7.0.2",
+    "rollup-plugin-typescript2": "^0.34.1",
+    "rollup-plugin-uglify": "^6.0.4",
     "storybook": "^7.0.15",
     "typescript": "^5.0.2",
     "vite": "^4.3.2"

二进制
qf-ui-v0.0.0.tgz


+ 37 - 0
rollup.config.js

@@ -0,0 +1,37 @@
+import commonjs from 'rollup-plugin-commonjs';
+import resolve from 'rollup-plugin-node-resolve';
+import { terser } from 'rollup-plugin-terser';
+import typescript from 'rollup-plugin-typescript2';
+import postcss from 'rollup-plugin-postcss';
+import babel from '@rollup/plugin-babel';
+
+export default {
+  input: 'src/index.ts',
+  output: [
+    {
+      file: 'dist/library.js',
+      format: 'cjs',
+      sourcemap: true,
+    },
+    {
+      file: 'dist/library.min.js',
+      format: 'cjs',
+      sourcemap: true,
+      plugins: [terser()],
+    },
+  ],
+  plugins: [
+    babel({
+        babelHelpers: 'bundled',
+        exclude: 'node_modules/**', // Exclude any unnecessary directories
+      }),
+    resolve(),
+    commonjs(),
+    typescript({
+      tsconfig: 'tsconfig.json',
+      allowImportPathExtension: true,
+    }),
+    postcss()
+  ],
+  external: ['react', 'react-dom', 'react/jsx-runtime'], // Specify any external dependencies here
+};

+ 1 - 0
src/index.ts

@@ -0,0 +1 @@
+export { default as MyComponent } from './stories/Button';

+ 1 - 1
src/main.tsx

@@ -1,6 +1,6 @@
 import React from 'react'
 import ReactDOM from 'react-dom/client'
-import App from './App.tsx'
+import App from './App'
 import './index.css'
 
 ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(

+ 2 - 1
src/stories/Button.tsx

@@ -1,4 +1,3 @@
-import React from 'react';
 import './button.css';
 
 interface ButtonProps {
@@ -46,3 +45,5 @@ export const Button = ({
     </button>
   );
 };
+
+export default Button;

+ 0 - 2
src/stories/Header.tsx

@@ -1,5 +1,3 @@
-import React from 'react';
-
 import { Button } from './Button';
 import './header.css';
 

+ 5 - 3
tsconfig.json

@@ -6,11 +6,13 @@
     "skipLibCheck": true,
 
     /* Bundler mode */
-    "moduleResolution": "bundler",
-    "allowImportingTsExtensions": true,
+    "allowJs": true,
+    "allowSyntheticDefaultImports": true,
+    "esModuleInterop": true,
+    "moduleResolution": "node",
+    "noEmit": true,
     "resolveJsonModule": true,
     "isolatedModules": true,
-    "noEmit": true,
     "jsx": "react-jsx",
 
     /* Linting */

文件差异内容过多而无法显示
+ 669 - 13
yarn.lock


部分文件因为文件数量过多而无法显示