Browserify 需要命令编辑器
Browserify require imperavi redactor
我想在我的 browserify 构建中需要 imperavi's redactor (npm package) 的代码。但是我得到了一个不可预测的错误。
这是react的element的代码
React = require('react')
ReactBootstrap = require('react-bootstrap')
Input = ReactBootstrap.Input
Button = ReactBootstrap.Button
require('bower-redactor/redactor/redactor-plugins/table.js')
require('bower-redactor/redactor/redactor.js')
require('bower-redactor/redactor/langs/ru.js')
module.exports = React.createClass
componentDidMount: ->
jQuery('textarea.redactor').redactor
lang: 'ru'
plugins: ['table']
render: ->
<form>
...
<Input type='textarea' ref='content' className='redactor' defaultValue={@props.content} />
...
</form>
一切顺利,直到我 require('bower-redactor/redactor/redactor-plugins/table.js')
并将 plugins: ['table']
添加到代码中。我收到一个错误:ReferenceError: RedactorPlugins is not defined
在 redactor.js#L1430
但是它们是在table.js定义的,这在redactor.js
之前是必需的redactor.js
为什么我会得到这个错误。我怎样才能避免它并开始成功使用redactor.js?
我尝试了很多东西:browserify-shim package、制作global.RedactorPlugins = {}
等等,但都没有成功。
您需要将代码包含在您的包中。它将是全球性的,因此您只需引用它。要求将不起作用。使用 gulp 它看起来像这样;
var source = {
libjs: ['bower-redactor/redactor/redactor-plugins/table.js', 'bower-redactor/redactor/redactor.js', 'bower-redactor/redactor/langs/ru.js']
};
gulp.task('libjs', function () {
gulp.src(source.libjs)
.pipe(concat('lib.min.js'))
.pipe(gulp.dest('./ui-dist'))
});
我想在我的 browserify 构建中需要 imperavi's redactor (npm package) 的代码。但是我得到了一个不可预测的错误。
这是react的element的代码
React = require('react')
ReactBootstrap = require('react-bootstrap')
Input = ReactBootstrap.Input
Button = ReactBootstrap.Button
require('bower-redactor/redactor/redactor-plugins/table.js')
require('bower-redactor/redactor/redactor.js')
require('bower-redactor/redactor/langs/ru.js')
module.exports = React.createClass
componentDidMount: ->
jQuery('textarea.redactor').redactor
lang: 'ru'
plugins: ['table']
render: ->
<form>
...
<Input type='textarea' ref='content' className='redactor' defaultValue={@props.content} />
...
</form>
一切顺利,直到我 require('bower-redactor/redactor/redactor-plugins/table.js')
并将 plugins: ['table']
添加到代码中。我收到一个错误:ReferenceError: RedactorPlugins is not defined
在 redactor.js#L1430
但是它们是在table.js定义的,这在redactor.js
之前是必需的redactor.js
为什么我会得到这个错误。我怎样才能避免它并开始成功使用redactor.js?
我尝试了很多东西:browserify-shim package、制作global.RedactorPlugins = {}
等等,但都没有成功。
您需要将代码包含在您的包中。它将是全球性的,因此您只需引用它。要求将不起作用。使用 gulp 它看起来像这样;
var source = {
libjs: ['bower-redactor/redactor/redactor-plugins/table.js', 'bower-redactor/redactor/redactor.js', 'bower-redactor/redactor/langs/ru.js']
};
gulp.task('libjs', function () {
gulp.src(source.libjs)
.pipe(concat('lib.min.js'))
.pipe(gulp.dest('./ui-dist'))
});