TypeError:尝试更改不可配置属性(Vue.js SPA)(Webpack 4)(iPhone 6S)(iOS Safari)的可枚举属性

时间:2018-07-29 11:02:32

标签: javascript webpack vue.js ecmascript-6 safari

(2018年7月29日)

1。背景(技术堆栈)

  • Vue.js 2(我正在使用vue-router Vuex构建单页应用程序(SPA)
  • Webpack 4

2。问题

在iOS Safari中访问我的网站,
屏幕变白(由于JS错误,因此没有呈现)

3。截图

enter image description here enter image description here

放大错误消息

enter image description here

3。错误消息

TypeError:尝试更改不可配置属性的可枚举属性。

4。如何复制?

  1. 访问https://browserstack.com
  2. 选择iPhone 6S Safari
  3. 访问https://wittcism.com

3。我的配置

/webpack.config.js

var path = require('path')
var webpack = require('webpack')
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin'); // https://github.com/webpack-contrib/copy-webpack-plugin

module.exports = {
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, './dist'),
    publicPath: '/dist/',
    filename: 'build.js',
  },
  module: {
    rules: [{
        test: /\.md$/,
        use: 'raw-loader'
      },
      {
        test: /\.css$/,
        use: [
          'vue-style-loader',
          'css-loader'
        ],
      },
      {
        test: /\.scss$/,
        use: [
          'vue-style-loader',
          'css-loader',
          'sass-loader'
        ],
      },
      {
        test: /\.sass$/,
        use: [
          'vue-style-loader',
          'css-loader',
          'sass-loader?indentedSyntax'
        ],
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
            // Since sass-loader (weirdly) has SCSS as its default parse mode, we map
            // the "scss" and "sass" values for the lang attribute to the right configs here.
            // other preprocessors should work out of the box, no loader config like this necessary.
            'scss': [
              'vue-style-loader',
              'css-loader',
              'sass-loader'
            ],
            'sass': [
              'vue-style-loader',
              'css-loader',
              'sass-loader?indentedSyntax'
            ]
          }
        }
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'file-loader',
        options: {
          name: '[name].[ext]?[hash]'
        }
      },
      {
        test: /\.html$/,
        use: [
          {
            loader: "html-loader",
            options: { minify: true }
          }
        ]
      }
    ]
  },
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.esm.js',
      '@': path.resolve(__dirname, './src/'),
    },
    extensions: ['*', '.js', '.vue', '.json']
  },
  devServer: {
    historyApiFallback: true,
    noInfo: true,
    overlay: true
  },
  performance: {
    hints: false
  },
  devtool: '#eval-source-map'
}

if (process.env.NODE_ENV === 'production') {
  module.exports.devtool = '#source-map'
  // http://vue-loader.vuejs.org/en/workflow/production.html
  module.exports.output = {
      path: path.resolve(__dirname, './dist'),
      publicPath: '/dist/',
      filename: '[name].[hash].js',
    },
    module.exports.plugins = (module.exports.plugins || []).concat([
      new webpack.DefinePlugin({
        'process.env': {
          NODE_ENV: '"production"'
        }
      }),
      new webpack.LoaderOptionsPlugin({
        minimize: true
      }),
      new CleanWebpackPlugin(['dist']),
      new HtmlWebpackPlugin({
        title: 'Wittcism',
        filename: './index.html',
        template: './template/index.html',
        minify: true,
      }),
    ])
}

.babelrc

{
  "presets": [
    ["env", { "modules": false }],
    "stage-3"
  ]
}

package.json

{
  "name": "hide",
  "description": "hide",
  "version": "1.1.0",
  "scripts": {
    "dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot --port 8081 --host 0.0.0.0",
    "build": "cross-env NODE_ENV=production webpack --mode production --progress --hide-modules"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "babel-polyfill": "^6.26.0",
    "bootstrap": "^4.1.1",
    "bootstrap-vue": "^2.0.0-rc.11",
    "es6-promise": "^4.2.4",
    "jstransformer-verbatim": "^1.1.1",
    "jwt-decode": "^2.2.0",
    "moment": "^2.22.2",
    "qiniu-js": "^2.4.0",
    "tippy.js": "^2.5.4",
    "tui-editor": "^1.2.3",
    "v-tooltip": "^2.0.0-rc.33",
    "vue": "^2.5.11",
    "vue-carousel": "^0.10.0",
    "vue-i18n": "^8.0.0",
    "vue-markdown": "^2.2.4",
    "vue-router": "^3.0.1",
    "vuelidate": "^0.7.4",
    "vuex": "^3.0.1"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "ie 6-8"
  ],
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.5",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-3": "^6.24.1",
    "clean-webpack-plugin": "^0.1.19",
    "copy-webpack-plugin": "^4.5.2",
    "cross-env": "^5.0.5",
    "css-loader": "^0.28.7",
    "file-loader": "^1.1.4",
    "html-loader": "^0.5.5",
    "html-webpack-plugin": "^3.2.0",
    "node-sass": "^4.9.0",
    "pug": "^2.0.3",
    "pug-loader": "^2.4.0",
    "raw-loader": "^0.5.1",
    "sass-loader": "^6.0.7",
    "style-loader": "^0.21.0",
    "vue-loader": "^14.2.2",
    "vue-template-compiler": "^2.4.4",
    "webpack": "^4.16.3",
    "webpack-bundle-analyzer": "^2.13.1",
    "webpack-cli": "^3.1.0",
    "webpack-dev-server": "^2.9.1"
  }
}

问题:如何解决:TypeError:尝试更改不可配置属性的可枚举属性?

我的猜测:iOS Safari不完全支持ES6

0 个答案:

没有答案