Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 在webpack捆绑包中包含配置文件_Node.js_Webpack - Fatal编程技术网

Node.js 在webpack捆绑包中包含配置文件

Node.js 在webpack捆绑包中包含配置文件,node.js,webpack,Node.js,Webpack,在我的webpack项目中,我想捆绑我的项目,并在其中包含一个示例使用文件。然而,当我以这种形式捆绑我的项目时 module.exports = { entry: { main: './src/main.js', about: './src/pages/config.js' }, output: { path: path.resolve(__dirname, 'dist'), filename: '[name].js', library: 'r

在我的webpack项目中,我想捆绑我的项目,并在其中包含一个示例使用文件。然而,当我以这种形式捆绑我的项目时

module.exports = {
  entry: {
    main: './src/main.js',
    about: './src/pages/config.js'
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].js',
    library: 'report' //makes this a global variable we can call from basic javascript page,
devtool: 'source-map',
  devServer: {
    port: 3001,
    clientLogLevel: 'none',
    stats: 'errors-only'
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader'] //npm install --save-dev style-loader css-loader
      }
    ]
  },
  plugins: [
    new CleanWebpackPlugin({ cleanStaleWebpackAssets: false }),
    new HtmlWebpackPlugin({
      title: 'ESS Map Learning',
    }),
  ],
};
  },

例如,dist中输出的文件被转换或加载为捆绑代码,无法读取。我正试图找到一种方法来加载此文件,使其不被更改,并以其原始格式保存在捆绑包中

不确定您想要实现什么?当我尝试捆绑我的“示例”文件时,它只是一些注释掉的代码,解释如何使用该程序,使用该程序的人需要这些代码作为解释,它被转换成bundle.js样式的代码,显然不是可读的形式。我想输出它,这样它就保持了它最初的类型。你的意思是你很想保留代码的注释,不是吗?您还可以共享完整的
webpack.config.js
文件吗?about页面是我希望保留的完整页面。它真的可能是一个txt文件,声音就像使用
模式构建:开发
会满足您的需要