gpt4 book ai didi

javascript - 如何在 webpack 中使用 noParse?

转载 作者:搜寻专家 更新时间:2023-10-31 23:26:22 25 4
gpt4 key购买 nike

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

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

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

的错误

ReferenceError: Unknown plugin "add-module-exports" specified in C:/..../node_modules\localforage\.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'
})
]
};

最佳答案

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

关于javascript - 如何在 webpack 中使用 noParse?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45244723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com