Javascript 添加网页包配置以使用react app rewired创建react app
警告:我是新手 我正在开发一个react应用程序,它通过纱线使用react创建应用程序 我正在尝试使用以下说明安装react wavesurfer 我需要让Wavesurfer.js以某种方式进入应用程序。这些说明包括对webpack配置进行更改,我试图避免将其弹出 我发现react应用程序重新布线,这篇文章 所以我将其添加到config-overrides.js中Javascript 添加网页包配置以使用react app rewired创建react app,javascript,reactjs,webpack,yarnpkg,wavesurfer.js,Javascript,Reactjs,Webpack,Yarnpkg,Wavesurfer.js,警告:我是新手 我正在开发一个react应用程序,它通过纱线使用react创建应用程序 我正在尝试使用以下说明安装react wavesurfer 我需要让Wavesurfer.js以某种方式进入应用程序。这些说明包括对webpack配置进行更改,我试图避免将其弹出 我发现react应用程序重新布线,这篇文章 所以我将其添加到config-overrides.js中 const rewireProvidePlugin = require('react-app-rewire-provide-pl
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
}
但我仍然无法访问包含这些导入的页面中的wavesurfer
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应用程序时,请重新布线启动
关于如何解决这个问题有什么线索吗 改用npm版本,将wavesurfer添加到依赖项下的package.json文件中,然后执行
npm安装
,或者如果使用的是yarn,则执行yarn安装
如何在项目内部使用
import WaveSurfer from 'wavesurfer.js';