From 679cc071609c03591531c64c7015eed6c02bf807 Mon Sep 17 00:00:00 2001 From: 406803045 <406803045@qq.com> Date: Thu, 6 Jun 2019 14:38:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3bable=20cannot=20call=20a=20c?= =?UTF-8?q?lass=20as=20a=20func?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .babelrc | 12 --------- babel.config.js | 1 - public/index.1.html | 27 -------------------- public/index.html | 9 +++++++ src/main.js | 2 +- src/permission.js | 8 ------ src/plugins/wechatAuth.js | 6 ++--- vue.config.js | 52 ++++++++++++++++++++++----------------- 8 files changed, 42 insertions(+), 75 deletions(-) delete mode 100644 .babelrc delete mode 100644 public/index.1.html diff --git a/.babelrc b/.babelrc deleted file mode 100644 index dc2f4b5..0000000 --- a/.babelrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "presets": [ - [ "@babel/preset-env", { - "targets": { - "browsers": [ "last 1 version", "ie >= 11" ] - } - }] - ], - "plugins": [ - "@babel/plugin-transform-runtime" - ] -} \ No newline at end of file diff --git a/babel.config.js b/babel.config.js index 9a68476..8c3d848 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,4 +1,3 @@ -process.env.VUE_CLI_BABEL_TRANSPILE_MODULES = true module.exports = { presets: [['@vue/app', { useBuiltIns: 'entry' }]], plugins: [ diff --git a/public/index.1.html b/public/index.1.html deleted file mode 100644 index 8f3b79a..0000000 --- a/public/index.1.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - <% for (var i in - htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %> - - - <% } %> - <%= webpackConfig.name %> - - - -
- - <% for (var i in - htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %> - - <% } %> - - - diff --git a/public/index.html b/public/index.html index 3384720..8f3b79a 100644 --- a/public/index.html +++ b/public/index.html @@ -5,6 +5,11 @@ + <% for (var i in + htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %> + + + <% } %> <%= webpackConfig.name %> @@ -13,6 +18,10 @@
+ <% for (var i in + htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %> + + <% } %> diff --git a/src/main.js b/src/main.js index 60926f5..9b39ec6 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,4 @@ import Vue from 'vue' -import '@babel/polyfill' import 'normalize.css/normalize.css' // A modern alternative to CSS resets import '@/assets/css/index.scss' // global css // 移动端适配 @@ -11,6 +10,7 @@ import '@/filters' // filters import '@/utils/directives' // directives import '@/permission' // permission control import wechatAuth from './plugins/wechatAuth' // 微信登录插件 + Vue.use(wechatAuth, { appid: process.env.VUE_APP_WECHAT_APPID }) diff --git a/src/permission.js b/src/permission.js index aa61f92..5fdc0bb 100644 --- a/src/permission.js +++ b/src/permission.js @@ -4,14 +4,6 @@ import getPageTitle from '@/utils/get-page-title' import wechatAuth from './plugins/wechatAuth' // 微信登录插件 const qs = require('qs') router.beforeEach((to, from, next) => { - // next() - // store.dispatch('user/fedLogOut').then(() => { - // // location.reload() - // }) - // store.dispatch('user/setLoginStatus', 0) - // alert(store.getters.loginStatus) - // return false - // alert(store.getters.loginStatus) const loginStatus = Number(store.getters.loginStatus) document.title = getPageTitle(to.meta.title) if (loginStatus === 0) { diff --git a/src/plugins/wechatAuth.js b/src/plugins/wechatAuth.js index 351f0c3..0617006 100644 --- a/src/plugins/wechatAuth.js +++ b/src/plugins/wechatAuth.js @@ -101,8 +101,8 @@ class VueWechatAuthPlugin { const vueWechatAuthPlugin = new VueWechatAuthPlugin() -if (typeof window !== 'undefined' && window.Vue) { - window.Vue.use(VueWechatAuthPlugin) -} +// if (typeof window !== 'undefined' && window.Vue) { +// window.Vue.use(VueWechatAuthPlugin) +// } export default vueWechatAuthPlugin diff --git a/vue.config.js b/vue.config.js index 98fe226..c81109a 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,5 +1,6 @@ 'use strict' const path = require('path') +const defaultSettings = require('./src/config/index.js') function resolve(dir) { return path.join(__dirname, dir) } @@ -24,7 +25,7 @@ const cdn = { build: { css: ['https://cdn.jsdelivr.net/npm/vant@beta/lib/index.css'], js: [ - // 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.4.4/polyfill.min.js', + 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.4.4/polyfill.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/vue-router/3.0.6/vue-router.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js', @@ -37,6 +38,7 @@ const cdn = { module.exports = { publicPath: process.env.NODE_ENV === 'production' ? '/antpublic/' : '/', outputDir: 'dist', + // outputDir: '../../../phpStudy/PHPTutorial/WWW/antpublic', assetsDir: 'static', lintOnSave: process.env.NODE_ENV === 'development', productionSourceMap: false, @@ -49,18 +51,23 @@ module.exports = { }, disableHostCheck: true }, - // configureWebpack: config => { - // // 为生产环境修改配置... - // if (process.env.NODE_ENV === 'production') { - // // externals里的模块不打包 - // Object.assign(config, { - // externals: externals - // }) - // } - // // 为开发环境修改配置... - // if (process.env.NODE_ENV === 'development') { - // } - // }, + configureWebpack: config => { + // 为生产环境修改配置... + if (process.env.NODE_ENV === 'production') { + // externals里的模块不打包 + Object.assign(config, { + name: defaultSettings.title, + // entry: ['@babel/polyfill', './src/main.js'], + externals: externals, + optimization: { + minimize: false + } + }) + } + // 为开发环境修改配置... + if (process.env.NODE_ENV === 'development') { + } + }, chainWebpack(config) { config.plugins.delete('preload') // TODO: need test config.plugins.delete('prefetch') // TODO: need test @@ -74,16 +81,15 @@ module.exports = { /** * 添加CDN参数到htmlWebpackPlugin配置中, 详见public/index.html 修改 */ - // config.plugin('html').tap(args => { - // if (process.env.NODE_ENV === 'production') { - // args[0].cdn = cdn.build - // } - // if (process.env.NODE_ENV === 'development') { - // args[0].cdn = cdn.dev - // } - // console.log(args) - // return args - // }) + config.plugin('html').tap(args => { + if (process.env.NODE_ENV === 'production') { + args[0].cdn = cdn.build + } + if (process.env.NODE_ENV === 'development') { + args[0].cdn = cdn.dev + } + return args + }) // set preserveWhitespace config.module