浏览代码

修改vite的配置,取消open

yangzhijie1488@163.com 4 年之前
父节点
当前提交
98e0de628b
共有 5 个文件被更改,包括 159 次插入6 次删除
  1. 23 0
      .vscode/settings.json
  2. 2 4
      package.json
  3. 2 2
      packages/date/src/Date.vue
  4. 74 0
      webpack.base1.js
  5. 58 0
      webpack.lib1.js

+ 23 - 0
.vscode/settings.json

@@ -0,0 +1,23 @@
+// 将设置放入此文件中以覆盖默认值和用户设置。
+{
+      "files.exclude": {
+            "**/node_modules": true,
+            "**/build": true,
+            "**/package-lock.json": true
+      },
+      "search.exclude": {
+            "**/node_modules": true,
+            "**/build": true,
+            "**/package-lock.json": true
+      },
+      // 保存后自动修复格式  
+      "editor.codeActionsOnSave": {
+            "source.fixAll.eslint": true
+      },
+      // 添加vue支持  
+      "eslint.validate": [
+            "javascript",
+            "javascriptreact",
+            "vue"
+      ]
+}

+ 2 - 4
package.json

@@ -1,6 +1,6 @@
 {
   "name": "pc-component-v3",
-  "version": "1.0.29",
+  "version": "1.0.30",
   "description": "",
   "main": "dist/pc-component-v3.js",
   "scripts": {
@@ -28,15 +28,13 @@
     "eslint-webpack-plugin": "^3.1.1",
     "file-loader": "^6.2.0",
     "html-webpack-plugin": "^5.5.0",
+    "mini-css-extract-plugin": "^2.6.0",
     "style-loader": "^3.3.1",
     "vue-loader": "^17.0.0",
     "webpack": "^5.70.0",
     "webpack-cli": "^4.9.2",
     "webpack-dev-server": "^4.7.4",
     "webpack-merge": "^5.8.0"
-  },
-  "dependencies": {
-    
   },
   "peerDependencies": {
     "amis": "^1.9.0",

+ 2 - 2
packages/date/src/Date.vue

@@ -108,7 +108,7 @@ export default {
           this.isValid = true;
         }
         console.log('Date input value changed: orginal value: %s, current value: %s', this.modelValue, newValue);
-        this.$emit('update:modelValue', newValue + ' 00:00:00');
+        this.$emit('update:modelValue', newValue);
       } else {
         this.isValid = false;
       }
@@ -133,7 +133,7 @@ export default {
           this.isValid = true;
         }
         console.log('Date value changed: orginal value: %s, current value: %s', newValue, parsedDateTime);
-        this.$emit('update:modelValue', parsedDateTime + ' 00:00:00');
+        this.$emit('update:modelValue', parsedDateTime);
       } else {
         this.isValid = false;
       }

+ 74 - 0
webpack.base1.js

@@ -0,0 +1,74 @@
+var path = require('path');
+var webpack = require('webpack');
+const { VueLoaderPlugin } = require('vue-loader');
+const ESLintPlugin = require('eslint-webpack-plugin');
+const MiniCssExtractPlugin = require('mini-css-extract-plugin');
+
+module.exports = {
+  module: {
+    rules: [
+      {
+        test: /\.vue$/,
+        loader: 'vue-loader',
+      },
+      {
+        // 使用babel-loader处理js文件,会将es5以上的语法进行转义(无法转义es6 API)
+        test: /\.js$/,    // 处理后缀名为js的文件
+        loader: 'babel-loader',     // 使用babel-loader进行处理
+        exclude: /node_modules/,    //排除node_modules下的文件
+        include: [path.resolve(__dirname, 'packages'), path.resolve(__dirname, 'examples')],
+        // options: {
+        //   presets: ["@babel/env"]
+        // }
+      },
+      {
+        test: /\.css$/,
+        use: (process.env.NODE_ENV === 'production') ? [
+          {
+            loader: MiniCssExtractPlugin.loader,
+            options: {
+              publicPath: '../',
+            },
+          },
+          'css-loader'] : ['style-loader', 'css-loader'],
+      },
+      {
+        test: /\.(png|jpg|gif|svg)$/,
+        loader: 'file-loader',
+        options: {
+          name: '[name].[ext]?[hash]',
+        },
+      },
+    ],
+  },
+
+  resolve: {
+    alias: {
+      '@': path.resolve(__dirname, 'packages'),
+    },
+    extensions: ['*', '.js', '.vue', '.json'],
+  },
+
+  performance: {
+    hints: false,
+  },
+  
+  // 不把第三方库打包到bundle中
+  externals: {
+    jQuery: 'window.$',
+    jquery: 'window.$',
+    $: 'window.$',
+    bootstrap: 'bootstrap',
+    moment: 'moment',
+  },
+  
+  plugins: [
+    new VueLoaderPlugin(),
+    new ESLintPlugin({
+      extensions: ['js', 'vue'],
+      // 自动修复。
+      // 自从eslint推出--fix命令后,如果觉得eslint格式化规则已经够用的话,其实也可以不用prettier了。
+      fix: true,
+    }),
+  ],
+};

+ 58 - 0
webpack.lib1.js

@@ -0,0 +1,58 @@
+var path = require('path');
+var webpack = require('webpack');
+const WebpackMerge = require('webpack-merge');
+const baseConfig = require('./webpack.base.js');
+
+module.exports = WebpackMerge.merge(baseConfig,{
+  mode: 'production',
+  
+  // 发布组件
+  entry: './packages/index.js',
+
+  output: {
+    path: path.resolve(__dirname, './dist'),
+    publicPath: '/dist/',
+    filename: 'pc-component-v3.js',
+    
+    // library: {
+    //   type: 'module',
+    // },
+    library: 'pc-component-v3',
+    libraryTarget: 'umd',
+    //「devtool 中模块」的文件名模板(用于冲突)
+    umdNamedDefine: false,
+  },
+
+  experiments: {
+    outputModule: true,
+  },
+
+  
+  optimization: {
+    minimize: true,    // 压缩 bundle
+  },
+  
+  //devtool: 'source-map',
+
+  plugins: (module.exports.plugins || []).concat([
+    new webpack.LoaderOptionsPlugin({
+      minimize: true,
+    }),
+  ]),
+
+  // 不把第三方库打包到bundle中
+  externals: {
+    jQuery: 'window.$',
+    jquery: 'window.$',
+    $: 'window.$',
+    'bootstrap': 'bootstrap',
+    'moment': 'moment',
+    // 不将vue代码打包进我们的组件库代码中,如果将vue代码打包进组件库中则会报错
+    'vue': 'vue',
+    'vue-i18n': 'vue-i18n',
+    'vue-router': 'vue-router',
+    'v-tooltip': 'v-tooltip',
+    'vuedraggable': 'vuedraggable',
+    'amis': 'amis',
+  },
+});