连接两个浏览器化文件(vendor.js 和 app.js 到 combine.js)时遇到问题
在浏览器中加载 combine.js 会在 _prelude.js 中引发以下内容:
Uncaught Error: Cannot find module 'function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}'
在单独加载浏览器化文件时工作得很好。
我错过了什么?
(如果您需要更多配置,请告诉我,很乐意提供)
谢谢你的帮助!
在 Gruntfile.js 中:
browserify: {
vendor: {
src: ['client/requires/**/*.js'],
dest: 'build/vendor.js',
options: {
shim: {
jquery: {
path: 'client/requires/jquery/js/jquery.js',
exports: '$'
},
underscore: {
path: 'client/requires/underscore/js/underscore.js',
exports: '_'
},
backbone: {
path: 'client/requires/backbone/js/backbone.js',
exports: 'Backbone',
depends: {
underscore: 'underscore'
}
},
'backbone.marionette': {
path: 'client/requires/backbone.marionette/js/backbone.marionette.js',
exports: 'Marionette',
depends: {
jquery: '$',
backbone: 'Backbone',
underscore: '_'
}
},
eventsource: {
path: 'client/requires/eventsource/eventsource.js',
exports: 'EventSource'
},
moment: {
path: 'client/requires/moment/moment.js',
exports: 'moment'
},
bootstrap: {
path: 'client/requires/bootstrap/js/bootstrap.js',
exports: null
}
}
}
},
app: {
files: {
'build/app.js': ['client/src/main.js']
},
options: {
transform: ['node-underscorify'],
debug: true,
external: ['jquery', 'underscore', 'backbone', 'backbone.marionette', 'eventsource', 'moment', 'bootstrap']
}
},
},
concat: {
'build/<%= pkg.name %>.js': ['build/vendor.js', 'build/app.js']
},