如何在webpack中使用noParse?

问题描述 投票:0回答:1

我想通过使用下面给我的这行代码将其从我的 webpack 文件中排除。

noParse: /node_modules\/localforage\/dist\/localforage.js/,

但无论我尝试什么,它都会不断说出像

这样的错误

ReferenceError:在 C:/..../node_modules\localforage\.babelrc 中指定的未知插件“add-module-exports”

这是我的 webpack 配置文件:

var path = require('path');
 var HtmlWebpackPlugin = require('html-webpack-plugin');

 module.exports = {
   entry: './app/index.js',
   output: {
     path: path.resolve(__dirname, 'dist'),
     filename: 'index_bundle.js',
     publicPath: '/'
   },
   devServer: {
    historyApiFallback: true,
  },
   module: {
     rules: [
       { test: /\.(js)$/, use: 'babel-loader' },

       { test: /\.css$/, use: [ 'style-loader', 'css-loader' ]}
     ]
   },
   plugins: [
     new HtmlWebpackPlugin({
       template: 'app/index.html'
     })
  ]
};
javascript node.js webpack webpack-dev-server
1个回答
0
投票

你可以使用

localForage 1.3+
版本的 webpack。您应该在配置中添加
noParse

var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
    entry: './app/index.js',
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'index_bundle.js',
        publicPath: '/'
    },
    devServer: {
        historyApiFallback: true,
    },
    module: {
        noParse: /node_modules\/localforage\/dist\/localforage.js/,
        rules: [{
            test: /\.(js)$/,
            exclude: /localforage/,
            use: 'babel-loader'
        }, {
            test: /\.css$ / ,
            use: ['style-loader', 'css-loader']
        }]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: 'app/index.html'
        })
    ]
};
© www.soinside.com 2019 - 2024. All rights reserved.