我正在使用strophe.js在聊天客户端上,我正在使用webpack导入所需的库。 所以在app.js中,我有
import '../lib/strophe.js';
import '../lib/strophe.muc.js';
但是我遇到了这个错误
ERROR in ./src/lib/strophe.muc.js
Module not found: Error: Can't resolve 'strophe.js' in 'C:\Prashant\my_code\XMPP\chat-client-poc\src\lib'
@ ./src/lib/strophe.muc.js 6:124-145 6:194-225
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/lib/strophe.muc.js
我的Webpack配置:-
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var webpack = require("webpack");
var extractPlugin = new ExtractTextPlugin({
filename: 'style.css'
});
module.exports = {
entry: './src/js/app.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
// publicPath: '/dist'
},
module: {
rules: [
{
test: /\.js$/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['es2015']
}
}
]
},
{
test:/\.css$/,
use: ['style-loader','css-loader', 'sass-loader']
},
{
test: /\.(jpg|png)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'img/',
publicPath: 'img/'
}
}
]
},
{
test: /\.html$/,
use: 'raw-loader'
},
]
},
plugins: [
extractPlugin,
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
new CleanWebpackPlugin(['dist'])
]
};
因此Strophe muc无法加载strophe。
Strophe.js https://gist.github.com/psahni/385de8b2303c5f150ab471e5bb4460c1
Strophe.muc.js https://gist.github.com/psahni/8a31cc4c32e059d3686cb7d5f4dc1822