如何在webpack中使用noParse?

wkyowqbh  于 2022-11-24  发布在  Webpack
关注(0)|答案(1)|浏览(154)

我想从我的webpack文件中排除这个,通过使用下面给我的这行代码。
noParse: /node_modules\/localforage\/dist\/localforage.js/,
但不管我怎么试,它总是说错误,比如
参考错误:在C:/..../node_modules\localfourse.babelrc中指定了未知插件“添加模块导出”
以下是我的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'
     })
  ]
};
jq6vz3qz

jq6vz3qz1#

您可以使用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'
        })
    ]
};

相关问题