我想在我的 Yeoman 项目中使用 browserify 而不是 RequireJS。你能告诉我如何把它换掉,这样我的 app/和 test/就可以利用 module.exports 和 require() 吗?
最佳答案
这是我所做的:
npm install grunt-browserify --save-dev
npm install coffeeify --save-dev
Gruntfile.js
中添加 grunt-browserify 步骤:browserify: {
basic: {
src: ['<%= yeoman.app %>/scripts/**/*.js', '<%= yeoman.app %>/scripts/**/*.coffee'],
options: {
transform: ['coffeeify']
},
dest: '.tmp/scripts/application.js'
}
}
concurrent: {
server: [
'...',
'browserify'
],
dist: [
'...',
'browserify'
]
}
watch: {
coffee: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
tasks: ['...', 'browserify']
}
}
<!-- build:js scripts/main.js -->
<script src="bower_components/jquery/jquery.js"></script>
<script src="scripts/main.js"></script>
<!-- endbuild -->
<!-- build:js(.tmp) scripts/coffee.js -->
<script src="scripts/hello.js"></script>
<!-- endbuild -->
对此:
<!-- build:js({.tmp,app}) scripts/main.js -->
<script src="bower_components/jquery/jquery.js"></script>
<script src="scripts/application.js"></script>
<!-- endbuild -->
关于javascript - 你如何将 browserify 添加到 yeoman 项目中?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17886902/