소스 검색

回退nuxt webpack配置打包问题

shenjunjie 7 년 전
부모
커밋
81aabf0624
5개의 변경된 파일90개의 추가작업 그리고 106개의 파일을 삭제
  1. 12 1
      .babelrc
  2. 59 94
      nuxt.config.js
  3. 14 6
      package.json
  4. 1 1
      pages/sassLogin/register.vue
  5. 4 4
      plugins/city-service.js

+ 12 - 1
.babelrc

@@ -1,3 +1,14 @@
 {
-  "presets": ["@nuxt/babel-preset-app"]
+  "presets": [
+    "es2015",
+    "stage-2"
+  ],
+  "plugins": [
+    ["transform-runtime", {
+      "helpers": false, // defaults to true
+      "polyfill": false, // defaults to true
+      "regenerator": false, // defaults to true
+      "moduleName": "babel-runtime" // defaults to "babel-runtime"
+    }]
+  ]
 }

+ 59 - 94
nuxt.config.js

@@ -11,68 +11,39 @@ module.exports = {
     mode: 'out-in'
   },
   /*
-   ** Headers of the page
-   */
+  ** Headers of the page
+  */
   head: {
     title: '账户中心',
-    meta: [{
-        charset: 'utf-8'
-      },
-      {
-        'http-equiv': 'X-UA-Compatible',
-        content: 'IE=edge,chrome=1'
-      },
-      {
-        name: 'render',
-        content: 'webkit'
-      },
-      {
-        name: 'viewport',
-        content: 'width=device-width, initial-scale=1'
-      },
-      {
-        hid: 'description',
-        name: 'description',
-        content: '账户中心'
-      }
+    meta: [
+      { charset: 'utf-8' },
+      { 'http-equiv': 'X-UA-Compatible', content: 'IE=edge,chrome=1' },
+      { name: 'render', content: 'webkit' },
+      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
+      { hid: 'description', name: 'description', content: '账户中心' }
     ],
-    link: [{
-      rel: 'icon',
-      type: 'image/x-icon',
-      href: '/U.png'
-    }]
+    link: [
+      { rel: 'icon', type: 'image/x-icon', href: '/U.png' }
+    ]
   },
   /*
-   ** Customize the progress-bar color
-   */
+  ** Customize the progress-bar color
+  */
   loading: '~components/common/nuxt-loading/Loading.vue',
   /*
-   ** Build configuration
-   */
+  ** Build configuration
+  */
   build: {
     /*
-     ** Run ESLINT on save
-     */
-    extractCSS: {
-      allChunks: true
-    },
-    extend(config, {
-      dev,
-      isClient,
-      isServer
-    }) {
-      Object.assign(config.resolve.alias, {
-        '~utils': path.resolve(__dirname, 'utils'),
-        '~components': path.join(__dirname, 'components'),
-        '~assets': path.join(__dirname, 'assets'),
-        '~plugins': path.join(__dirname, 'plugins'),
-        '~store': path.join(__dirname, 'store')
-      })
-      // config.resolve.alias['~utils'] = path.join(__dirname, 'utils')
-      // config.resolve.alias['~components'] = path.join(__dirname, 'components')
-      // config.resolve.alias['assets'] = path.join(__dirname, './assets')
-      // config.resolve.alias['~plugins'] = path.join(__dirname, 'plugins')
-      // config.resolve.alias['~store'] = path.join(__dirname, 'store')
+    ** Run ESLINT on save
+    */
+    extractCSS: { allChunks: true },
+    extend (config, { dev, isClient, isServer }) {
+      config.resolve.alias['~utils'] = path.join(__dirname, 'utils')
+      config.resolve.alias['~components'] = path.join(__dirname, 'components')
+      config.resolve.alias['~assets'] = path.join(__dirname, 'assets')
+      config.resolve.alias['~plugins'] = path.join(__dirname, 'plugins')
+      config.resolve.alias['~store'] = path.join(__dirname, 'store')
       // config.module.rules.push({
       //   test: /\.scss$/,
       //   loader: 'vue-style-loader!css-loader!sass-loader'
@@ -96,29 +67,24 @@ module.exports = {
       'mint-ui',
       'vuerify',
       'vee-validate'
+    ],
+    babel: {
+      presets: ['es2015', 'stage-2'],
+      plugins: [
+        'transform-async-to-generator',
+        'transform-runtime'
+      ],
+      comments: true
+    },
+    postcss: [
+      require('autoprefixer')({
+        browsers: ['last 3 versions']
+      })
     ]
-    // babel: {
-    //   presets: ['es2015', 'stage-2'],
-    //   plugins: [
-    //     'transform-async-to-generator',
-    //     'transform-runtime'
-    //   ],
-    //   comments: true
-    // },
-    // postcss: [
-    //   require('autoprefixer')({
-    //     browsers: ['last 3 versions']
-    //   })
-    // ]
   },
-  css: [{
-      src: '~assets/scss/mobileCommon.scss',
-      lang: 'scss'
-    },
-    {
-      src: '~assets/scss/app.scss',
-      lang: 'scss'
-    }
+  css: [
+    {src: '~assets/scss/mobileCommon.scss', lang: 'scss'},
+    {src: '~assets/scss/app.scss', lang: 'scss'}
   ],
   dev: !isProdMode,
   env: {
@@ -128,27 +94,26 @@ module.exports = {
     // {
     //   src: '~plugins/axios-nuxt.js'
     // },
-    //   {
-    //   src: '~plugins/axios.js'
-    // },
+  //   {
+  //   src: '~plugins/axios.js'
+  // },
     {
-      src: '~plugins/element-ui.js'
-    }, {
-      src: '~plugins/mint-ui.js'
-    }, {
-      src: '~plugins/filters.js',
-      ssr: false
-    }, {
-      src: '~plugins/jsonp.js',
-      ssr: false
-    }, {
-      src: '~plugins/vuerify.js',
-      ssr: false
-    }, {
-      src: '~plugins/vee-validate.js',
-      ssr: true
-    }
-  ],
+    src: '~plugins/element-ui.js'
+  }, {
+    src: '~plugins/mint-ui.js'
+  }, {
+    src: '~plugins/filters.js',
+    ssr: false
+  }, {
+    src: '~plugins/jsonp.js',
+    ssr: false
+  }, {
+    src: '~plugins/vuerify.js',
+    ssr: false
+  }, {
+    src: '~plugins/vee-validate.js',
+    ssr: true
+  }],
   /* TODO 代理 */
   proxyTable: ['/api/**', '/login/**', '/user**', '/logout**', '/sso/**', '/appeal/**', '/update/user/**', '/valid/**', '/im/**', '/weChat/**', '/bh/**', '/foreign/**']
 }

+ 14 - 6
package.json

@@ -18,7 +18,7 @@
     "js-md5": "^0.7.3",
     "jsonp": "^0.2.1",
     "mint-ui": "^2.2.13",
-    "nuxt": "2.0.0",
+    "nuxt": "^2.0.0",
     "v-vuerify-next": "^0.2.0",
     "vee-validate": "^2.0.0",
     "vue-awesome-swiper": "^2.5.4",
@@ -39,17 +39,25 @@
     "precommit": "npm run lint"
   },
   "devDependencies": {
-    "babel-eslint": "^10.0.1",
+    "babel-plugin-component": "^0.10.1",
+    "babel-plugin-external-helpers": "^6.22.0",
+    "babel-cli": "^6.24.1",
+    "babel-core": "^6.26.0",
+    "babel-eslint": "^7.1.1",
+    "babel-loader": "^7.1.1",
+    "babel-plugin-transform-runtime": "^6.23.0",
+    "babel-preset-es2015": "^6.24.1",
+    "babel-preset-stage-2": "^6.24.1",
     "css-loader": "^0.28.7",
-    "node-sass": "^4.11.0",
-    "sass-loader": "^7.1.0",
     "eslint": "^4.13.0",
+    "eslint-plugin-flowtype": "^2.49.3",
     "eslint-config-standard": "^6.2.1",
     "eslint-loader": "^1.6.1",
-    "eslint-plugin-flowtype": "^2.49.3",
     "eslint-plugin-html": "^2.0.0",
     "eslint-plugin-promise": "^3.4.1",
     "eslint-plugin-standard": "^2.0.1",
-    "nodemon": "^1.14.11"
+    "node-sass": "^4.9.0",
+    "nodemon": "^1.14.11",
+    "sass-loader": "^6.0.6"
   }
 }

+ 1 - 1
pages/sassLogin/register.vue

@@ -135,8 +135,8 @@
                       return Promise.reject(response.data)
                     }
                   }).catch(err => {
-                    this.$message.error(err.errMsg)
                     // this.codeErrorMsg = err.errMsg
+                    this.$message.error(err.errMsg)
                   })
               } else {
                 callback(new Error('请输入正确的验证码'))

+ 4 - 4
plugins/city-service.js

@@ -1,5 +1,5 @@
 import axios from 'axios'
-// import store from '~store'
+import store from '~store'
 
 const service = axios.create({
   withCredentials: true,
@@ -10,8 +10,8 @@ service.interceptors.request.use(config => {
   // is server render, use ${baseUrl} directly rather than ${proxyUrl}
   if (typeof window === 'undefined') {
     config.url = process.env.baseUrl + '/city/' + process.env.cityDomain + config.url
-    // config.headers.cookie = store.state.option.cookies + '; ' + store.state.option.sessionId
-    // config.headers['User-Agent'] = store.state.option.userAgent
+    config.headers.cookie = store.state.option.cookies + '; ' + store.state.option.sessionId
+    config.headers['User-Agent'] = store.state.option.userAgent
   } else {
     config.url = '/city/' + process.env.cityDomain + config.url
   }
@@ -30,7 +30,7 @@ service.interceptors.response.use(response => {
         const first = sessionId.indexOf(';')
         const second = sessionId.lastIndexOf(';')
         const newSessionId = sessionId.replace(sessionId.substring(first, second), '')
-        // store.commit('option/SET_SESSION_ID', newSessionId)
+        store.commit('option/SET_SESSION_ID', newSessionId)
         break
       }
     }