فهرست منبع

chore:引入webpack,待路径调试配置

徐志豪 5 سال پیش
والد
کامیت
d60f732220
11فایلهای تغییر یافته به همراه1367 افزوده شده و 35 حذف شده
  1. 3 0
      .babelrc
  2. 2 1
      .gitignore
  3. 1 1
      admins/fd-mall-backstage/js/sys/user.js
  4. 1 1
      admins/zl-mall-backstage/js/sys/user.js
  5. 21 0
      build/copyPlugins.js
  6. 22 0
      build/htmlPlugins.js
  7. 23 0
      build/jsEntry.js
  8. 12 31
      build/webpack.dev.config.js
  9. 1 1
      js/sys/user.js
  10. 1278 0
      package-lock.json
  11. 3 0
      package.json

+ 3 - 0
.babelrc

@@ -0,0 +1,3 @@
+{
+  "presets": ["@babel/preset-env"]
+}

+ 2 - 1
.gitignore

@@ -1,2 +1,3 @@
 node_modules
-dist
+dist
+.tmp

+ 1 - 1
admins/fd-mall-backstage/js/sys/user.js

@@ -180,7 +180,7 @@ var vm = new Vue({
                                 that.user.brandList.forEach(function(sub){
                                     // item['checked'] = false
                                     if (item.id===sub.brandId||item.id===sub.id) {
-                                        item['checked'] = true
+                                    item['checked'] = true
                                         return
                                     }
                                 })

+ 1 - 1
admins/zl-mall-backstage/js/sys/user.js

@@ -180,7 +180,7 @@ var vm = new Vue({
                                 that.user.brandList.forEach(function(sub){
                                     // item['checked'] = false
                                     if (item.id===sub.brandId||item.id===sub.id) {
-                                        item['checked'] = true
+                                    item['checked'] = true
                                         return
                                     }
                                 })

+ 21 - 0
build/copyPlugins.js

@@ -0,0 +1,21 @@
+const fs = require('fs')
+const path = require('path')
+const adminPath = 'admins'
+// 获取 admins 目录下的后台管理系统文件名并指定公共文件目录命名
+function resolve (dir) {
+  return path.resolve(__dirname, '../', dir)
+}
+const files = fs.readdirSync(resolve(adminPath))
+function copyToApps(dir) {
+  let r = []
+  
+    files.map(app => {
+      r.push({
+        from: resolve(dir),
+        to: resolve(`${adminPath}/${app}/${dir}`)
+      })
+    })
+  return r
+}
+
+module.exports = copyToApps

+ 22 - 0
build/htmlPlugins.js

@@ -0,0 +1,22 @@
+
+let htmlPluginsArr = []
+const HtmlWebpackPlugin = require('html-webpack-plugin')
+const adminPath = 'admins'
+const fs = require('fs')
+const path = require('path')
+const files = fs.readdirSync(resolve(adminPath))
+
+function resolve (dir) {
+  return path.resolve(__dirname, '../', dir)
+}
+files.map(app => {
+  const config = require(`./../admins/${app}/config/config.js`)
+  htmlPluginsArr.push(new HtmlWebpackPlugin({
+    filename: `./../admins/${app}/index.html`,
+    template: 'index.html',
+    title: config.title,
+    navTitle: config.navTitle
+  }))
+})
+
+module.exports = htmlPluginsArr

+ 23 - 0
build/jsEntry.js

@@ -0,0 +1,23 @@
+let entrys = {}
+const path = require('path')
+const fs = require('fs')
+function resolve (dir) {
+  return path.resolve(__dirname, '../', dir)
+}
+
+function getEntry (path) {
+  let jss = fs.readdirSync(resolve(path))
+  jss.forEach(item => {
+    let stats = fs.statSync(resolve(`${path}/${item}`))
+    if (stats.isFile()) {
+      
+      const name = item.match(/(\S+).js/)[1]
+      entrys[name] = resolve(`${path}/${name}`)
+    } else {
+      getEntry(`${path}/${item}`)
+    }
+  })
+}
+getEntry('js')
+// console.log(entrys)
+module.exports = entrys

+ 12 - 31
build/webpack.dev.config.js

@@ -1,51 +1,32 @@
 const CopyWebpackPlugin = require('copy-webpack-plugin')
-const HtmlWebpackPlugin = require('html-webpack-plugin')
+const copyToApps = require('./copyPlugins')
+const htmlPluginsArr = require('./htmlPlugins')
 const path = require('path')
-let fs = require('fs')
-const adminPath = 'admins'
+const entrys = require('./jsEntry')
 function resolve (dir) {
     return path.resolve(__dirname, '../', dir)
 }
-
-// 获取 admins 目录下的后台管理系统文件名并指定公共文件目录命名
-const files = fs.readdirSync(resolve(adminPath))
-function copyToApps(dir) {
-  let r = []
-  
-    files.map(app => {
-      r.push({
-        from: resolve(dir),
-        to: resolve(`${adminPath}/${app}/${dir}`)
-      })
-    })
-
-  return r
-}
-let htmlPluginsArr = []
-files.map(app => {
-  const config = require(`./../admins/${app}/config/config.js`)
-  htmlPluginsArr.push(new HtmlWebpackPlugin({
-    filename: `./../admins/${app}/index.html`,
-    template: 'index.html',
-    title: config.title,
-    navTitle: config.navTitle
-  }))
-})
+console.log(entrys)
 
 module.exports = {
     mode: 'development',
     watch: true,
-  entry: resolve('index.js'),
+  entry: entrys,
 
   output: {
-    path: resolve('.tmp'),
-    filename: 'bundle.js'
+    path: resolve('admins/zl-mall-backstage/dist/js'),
+    filename: '[name].js'
   },
   devServer: {
       hot: true,
       port: 9000,
       contentBase: false
   },
+  module: {
+    rules: [
+      { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
+    ]
+  },
   plugins: [
     new CopyWebpackPlugin([
       ...copyToApps('statics'),

+ 1 - 1
js/sys/user.js

@@ -179,7 +179,7 @@ var vm = new Vue({
                             if (that.user.brandList) {
                                 that.user.brandList.forEach(function(sub){
                                     // item['checked'] = false
-                                    if (item.id===sub.brandId) {
+                                    if (item.id===sub.brandId||item.id===sub.id) {
                                     item['checked'] = true
                                         return
                                     }

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1278 - 0
package-lock.json


+ 3 - 0
package.json

@@ -13,6 +13,9 @@
   "author": "",
   "license": "ISC",
   "devDependencies": {
+    "@babel/core": "^7.9.0",
+    "@babel/preset-env": "^7.9.5",
+    "babel-loader": "^8.1.0",
     "copy-webpack-plugin": "^5.1.1",
     "html-webpack-plugin": "^4.2.0",
     "webpack": "^4.42.1",