Comments (3)
一个可行的配置是这样(附在最后面):它会将src/dialog.js和它的所有依赖合并成build/src/dialog.js。其他没有被合并的文件则被复制到build/目录。
前提是所有var $ = require('jquery')
都要被删除。因为你的项目里面的jquery是放在里lib/目录里面,而要合并的目标则是在src/目录里。
grunt-seajs-build因为某种原因不能将jquery合并进来(具体是什么原因我不太确定,因为这个代码实在是很久之前写的,要么是因为jquery不是合法的seajs模块,要么是因为jquery所在的目录不是在target所在的目录的下面。)
如果你不想将var $ = require('jquery')
删掉,可以试试参考example/complex (https://github.com/WarWithinMe/grunt-seajs-build/blob/master/examples/complex) 的配置来试一下。先将jquery编译成lib。然后再将jquery的路径通过resolveID来映射到lib的路径。(又或者用hack的手段,在src/目录建立一个jquery.js,里面定义一个空的seajs模块。)
不过项目构建还真的不应该用config来写,因为每个项目会有各种各样的需求。。:disappointed:
配置:
module.exports = function(grunt) {
grunt.initConfig({
"seajs_build" : {
options : {
outputPath : "build"
, seajsBasePath : "src"
, path : "."
, scheme : null
, alias : null
, recursive : true
, buildType : "exclude_merge"
}
, main : {
options : { path : "." }
, files : [
{
src : "src/dialog.js"
, dest : "src/dialog.js"
, filter : "isFile"
, concatDeps : true
}
]
}
}
});
grunt.loadNpmTasks('grunt-seajs-build');
grunt.registerTask("default", ['seajs_build']);
}
from grunt-seajs-build.
谢谢,我用grunt-cmd-transport和grunt-cmd-concat解决了。确实这种配置更适合个人项目。
from grunt-seajs-build.
你好,在运行的时候看见日志这么记录
File : [static/js/modules/helloworld/hello.js] >>>> ID : "../static\js\modules\helloworld\hello.js"
为什么给加上“../”呢?
from grunt-seajs-build.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-seajs-build.