警告:我是新手。
我正在使用通过纱线使用react-create-app的反应应用程序。
我尝试使用这些说明安装react-wavesurfer https://github.com/mspae/react-wavesurfer#prerequisites-and-common-pitfalls
我需要以某种方式将Wavesurfer.js放入应用程序中。这些说明包括更改webpack配置,我试图避免弹出。
我发现这个反应应用程序重新连接,本文https://jaketrent.com/post/change-webpack-config-create-react-app-without-ejecting/
所以我已将此添加到config-overrides.js
const rewireProvidePlugin = require('react-app-rewire-provide-plugin')
// Use `webpack.ProvidePlugin` to add jQuery globally
module.exports = function override(config, env) {
// add a plugin
config = rewireProvidePlugin(config, env, {
'WaveSurfer': 'wavesurfer.js',
})
resolve: {
alias: {
wavesurfer: require.resolve('wavesurfer.js')
}
}
return config
}
哪些版本,但我仍然无法在具有这些导入的页面中访问waveurfer
import React, {Component} from 'react'
import history from '../../../history'
import Wavesurfer from 'react-wavesurfer'
import * as _ from 'lodash'
require('wavesurfer.js')
require('wavesurfer.js/dist/plugin/wavesurfer.timeline.min.js')
require('wavesurfer.js/dist/plugin/wavesurfer.regions.min.js')
require('wavesurfer.js/dist/plugin/wavesurfer.minimap.min.js')
当我尝试运行react-app-rewired start
时有关如何解决此问题的任何线索?
答案 0 :(得分:0)
改为使用npm版本,将wavesurfer添加到依赖项下的package.json文件中,然后执行npm install
,或者如果您使用yarn则执行yarn install
如何在项目内部使用
import WaveSurfer from 'wavesurfer.js';