@tsingroc/tsingroc-components 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.babelrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "presets": ["@babel/preset-env", "@babel/preset-react"]
3
+ }
@@ -0,0 +1,55 @@
1
+ const path = require('path');
2
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
3
+
4
+ module.exports = {
5
+ mode: 'development', // 或 'production'
6
+ entry: './src/index.js', // 入口文件
7
+ output: {
8
+ path: path.resolve(__dirname, 'dist'), // 输出目录
9
+ filename: 'bundle.js', // 输出文件名
10
+ library: 'my-component-library',
11
+ libraryTarget: 'umd',
12
+ },
13
+ // devServer: {
14
+ // contentBase: path.join(__dirname, 'public'), // 静态文件目录
15
+ // compress: true,
16
+ // port: 8080, // 开发服务器端口
17
+ // },
18
+ plugins: [
19
+ new HtmlWebpackPlugin({
20
+ template: './example/public/index.html', // 使用 src/index.html 作为模板
21
+ }),
22
+ ],
23
+ externals: {
24
+ react: {
25
+ commonjs: 'react',
26
+ commonjs2: 'react',
27
+ amd: 'react',
28
+ root: 'React' // 全局变量
29
+ },
30
+ 'react-dom': {
31
+ commonjs: 'react-dom',
32
+ commonjs2: 'react-dom',
33
+ amd: 'react-dom',
34
+ root: 'ReactDOM'
35
+ }
36
+ },
37
+ module: {
38
+ rules: [
39
+ {
40
+ test: /\.css$/, // CSS 文件处理
41
+ use: ['style-loader', 'css-loader'],
42
+ },
43
+ {
44
+ test: /\.js$/, // 处理 JavaScript 文件
45
+ exclude: /node_modules/,
46
+ use: {
47
+ loader: 'babel-loader',
48
+ options: {
49
+ presets: ['@babel/preset-env', '@babel/preset-react'], // 转译 ES6+ 和 JSX
50
+ },
51
+ },
52
+ },
53
+ ],
54
+ },
55
+ };