Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
280 views
in Technique[技术] by (71.8m points)

debugging - Failed to open eval code with webpack and Edge

I'm not well versed with webpack and have been running into this problem that makes debugging very difficult: When an error occurs, the line that caused the error doesn't appear. Instead, the debugger simply outputs Failed to open eval code (301).

I'm working on an Office add-in with office-js, and using webpack to build for production, as well as running the dev server locally.

Below is my webpack.dev.config. It's mostly a mish-mash of examples and suggestions I found online, so there probably are many errors and room for improvement:

const path = require('path')
const HtmlWebPackPlugin = require("html-webpack-plugin")
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

  module.exports = {
    mode: 'development',
    entry: ['react-hot-loader/patch', './src/js/index.js'],
    output: {
      path: path.join(__dirname, 'dist'),
      publicPath: '/',
      filename: '[name].js'
    },
    target: 'web',
    devtool: 'eval',
    resolve: {
      extensions: ['.html', '.js']
    },
    node: {
      fs: 'empty',
    },
    optimization: {
      minimize: false
    },
    devServer: {
        contentBase: path.join(__dirname, 'dist'),
        compress: true,
        port: 3000
      },
    module: {
      rules: [
        {
          test: /.js$/,
          exclude: /node_modules/,
          loader: "babel-loader",
        },
        {
          // Loads the javacript into html template provided.
          // Entry point is set below in HtmlWebPackPlugin in Plugins
          test: /.html$/,
          use: [
            {
              loader: "html-loader",
              //options: { minimize: true }
            }
          ]
        },
        {
          test: /.css$/,
          use: [ 'style-loader', 'css-loader' ]
        },
        {
         test: /.(png|svg|jpg|gif)$/,
         use: ['file-loader']
        }
      ]
    },
    plugins: [
        new CleanWebpackPlugin(),
        new HtmlWebPackPlugin({
        template: "./src/html/index.html",
        filename: "./index.html",
        excludeChunks: [ 'server' ]
      })
    ]
  };

And this is a screenshot of the Edge debugger (Office addins are run on an Edge instance inside the Office application):

enter image description here

Any help, suggestions and corrections are very much appreciated. Thanks in advance.

question from:https://stackoverflow.com/questions/65830181/failed-to-open-eval-code-with-webpack-and-edge

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...