带有服务器生成的JS文件的RequireJS
我将RequireJS与服务器生成的文件一起使用,该文件包含翻译字符串,可在带有服务器生成的JS文件的RequireJS,requirejs,gruntjs,Requirejs,Gruntjs,我将RequireJS与服务器生成的文件一起使用,该文件包含翻译字符串,可在http://hostname/i18n.js。我已将其添加到RequireJS中,路径为pathconfig,如下所示: requirejs.config({ paths: { 'i18n': '/i18n' }, }); 现在,我正试图用grunt contrib requirejs'将其缩小,如下所示: module.exports = function(grunt) { 'u
http://hostname/i18n.js
。我已将其添加到RequireJS中,路径为path
config,如下所示:
requirejs.config({
paths: {
'i18n': '/i18n'
},
});
现在,我正试图用grunt contrib requirejs'
将其缩小,如下所示:
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'), // the package file to use
jsDir: '<%= baseDir %>/static/js',
requirejs: {
compile: {
options: {
mainConfigFile: "<%= jsDir %>/common.js",
dir: '/tmp/www-release',
modules : [
{
name: 'common',
exclude: ['i18n'],
include: [
/* some filess */
]
}
]
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-requirejs');
};
如何让grunt忽略翻译字符串?是引用i18n的“common”中的内容吗?不是,common只包含requirejs.config。但是,
中的一些文件包含
以引用它是从包含文件中引用的带有require或define?i18n在不同的文件中同时引用了require
和define
。
Running "requirejs:compile" (requirejs) task
[Error: Error: ENOENT, no such file or directory '/i18n.js'
at Object.fs.openSync (fs.js:427:18)
]