jwvdiermen / grunt-include-source Goto Github PK
View Code? Open in Web Editor NEWInclude lists of files into your source files automatically.
License: MIT License
Include lists of files into your source files automatically.
License: MIT License
Running wiredep after doing an includeSource breaks my index.html, but only on Windows machines. Works fine in OS X. Changing line 204 of includeSource.js to .join('\r\n'); fixes the issue.
Hi,
I'm getting the error about and it does seem very helpful. I even get it when I am running the unit test.
xxxxxxxxxxxx:grunt-include-source xxxxxxxxx$ grunt includeSource
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Initializing config...OK
Registering "tasks" tasks.
Loading "includeSource.js" tasks...OK
Registering "grunt-contrib-jshint" local Npm module tasks.
Reading /Users/tmckeown/Documents/Aptana Studio 3 Workspace/book_example/node_modules/grunt-include-source/node_modules/grunt-contrib-jshint/package.json...OK
Parsing /Users/tmckeown/Documents/Aptana Studio 3 Workspace/book_example/node_modules/grunt-include-source/node_modules/grunt-contrib-jshint/package.json...OK
Loading "jshint.js" tasks...OK
Registering "grunt-contrib-clean" local Npm module tasks.
Reading /Users/tmckeown/Documents/Aptana Studio 3 Workspace/book_example/node_modules/grunt-include-source/node_modules/grunt-contrib-clean/package.json...OK
Parsing /Users/tmckeown/Documents/Aptana Studio 3 Workspace/book_example/node_modules/grunt-include-source/node_modules/grunt-contrib-clean/package.json...OK
Loading "clean.js" tasks...OK
Registering "grunt-contrib-nodeunit" local Npm module tasks.
Reading /Users/tmckeown/Documents/Aptana Studio 3 Workspace/book_example/node_modules/grunt-include-source/node_modules/grunt-contrib-nodeunit/package.json...OK
Parsing /Users/tmckeown/Documents/Aptana Studio 3 Workspace/book_example/node_modules/grunt-include-source/node_modules/grunt-contrib-nodeunit/package.json...OK
Loading "nodeunit.js" tasks...OK
Registering "grunt-lineending" local Npm module tasks.
Reading /Users/tmckeown/Documents/Aptana Studio 3 Workspace/book_example/node_modules/grunt-include-source/node_modules/grunt-lineending/package.json...OK
Parsing /Users/tmckeown/Documents/Aptana Studio 3 Workspace/book_example/node_modules/grunt-include-source/node_modules/grunt-lineending/package.json...OK
Loading "lineending.js" tasks...OK
Running tasks: includeSource
Running "includeSource" task
Running "includeSource:baseUrlHtmlTest" (includeSource) task
Verifying property includeSource.baseUrlHtmlTest exists in config...OK
Files: test/files/baseUrl.html -> tmp/baseUrl.html
Options: basePath="test/files", baseUrl="test/files/", templates={}, typeMappings={}, rename=undefined
Warning: Symbol is not defined Use --force to continue.
Aborted due to warnings.
Unfortunately, the option 'top-down' doesn't work. This is my config:
includeSource: {
options: {
basePath: 'app',
baseUrl: '/',
ordering: 'top-down'
},
server: {
files: {
'.tmp/index.html': '<%= yeoman.app %>/index.html'
}
},
dist: {
files: {
'<%= yeoman.dist %>/index.html': '<%= yeoman.app %>/index.html'
}
}
}
<!-- include: "type": "js", "files": "<%= path.temp %>/js/i18n/**/*.js" -->
Is not doing what was expected. Would be nice to have this )
On the documentation where you demonstrate how to override the default 'template', it needs to be 'templates' to match what you have in your source. Took me a while to realize I was doing it wrong :)
Side note: I love grunt-include-source, thanks!
Support for bower components is currently based on a "sources" attribute, which is pretty rare in bower components. On the other hand, the bower specification almost enforces the existence of a "main" attribute that lists the main distrib files of the component. Why not use this attribute instead (similarly to https://github.com/yatskevich/grunt-bower-task)?
Hello,
I want to overwrite the include in my html file but I does not seem to work. the <!-- /include-->
is ignored. It has the exact same behavior with or without this html comment.
Is this a bug or I am misusing it.
Best,
Guillaume Leclerc
TO DELETE
Globbing includes duplicates.
Hi there!
First of all let me say that this is a wonderful idea and that's exactly what I'm looking for our project.
Unfortunately id does not work. Here I composed a test grunt setup with only one task and a setup from your documentation to illustrate just that:
https://github.com/dmitrybelyakov/grunt-include-source
I'll investigate further and post back if I find the issue.
Have a great day!
Is there any way to exclude some paths/files globally on the main config?
On the include part, we can do it by !dont-include/*.scss
But it could be beneficial to do it globally, for example to exclude .spec files, etc...
Loading "include_source.js" tasks...ERROR
Error: Cannot find module 'extendr'
installing extendr module by "npm install extendr --save-dev" resolved the problem
Scripts have default type "application/javascript"
and even old browsers interpret script tags without the type
attribute as JavaScript scripts. On the other hand, the "text/javascript"
MIME type is deprecated for JavaScript but explicitly specifying type="application/javascript"
is not recognized by older IEs.
In other words, the only way to be both conformant to the spec and to not specify an obsolete MIME type is to omit the type
attribute completely. Works everywhere and is less verbose so it's easier to read it.
Add an ability to write to the same file where include comment is, not to make a copy.
var appConfig = {
app : 'src/app',
dist : 'src/dist',
tmp : 'src/.tmp',
test : 'src/test',
};
// Define the configuration for all the tasks
grunt.initConfig({
// Project settings
yeoman : appConfig,
...ahead...
// grunt-include-source
// Include your sources into your HTML files automatically.
includeSource : {
options : {
basePath : '<%= yeoman.app %>',
baseUrl : '/'
},
server : {
files : {
'<%= yeoman.tmp %>/index.html' : '<%= yeoman.app %>/index.html'
}
},
dist : {
files : {
'<%= yeoman.dist %>/index.html' : '<%= yeoman.app %>/index.html'
}
}
}
});
html
The task works fine when I do grunt build
But I cannot get it to work with a grunt server
I've tried to add 'includeSource' at the begining of the grunt server tasks (without success):
grunt.registerTask('server', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'connect:dist:keepalive']);
}
grunt.task.run([
'includeSource',
'preprocess:multifile',
'clean:server',
'concurrent:server',
'autoprefixer',
'connect:livereload',
'watch'
]);
});
Then I do: grunt server
, the task is not called and there is still <!-- include: "type": "js", "files": "scripts/**/*.js" -->
in index.html
, and nothing in .tmp
or dist
.
Is it supposed to work with grunt server ? And if so, how ?
I am currently working on a project with JSP files as index page. And on other projects where we used include source - everything work fine.
I updated the objects: parsers, endMarkerParsers and templates as follows:
It would be nice to have same functionality for JavaScript files. i.e. karma.conf.js file. Sometimes specifing file pattern isn't enough. Would be nice to have a way, to include files there as well.
i.e.
options: {
// ...
js: {
js: 'app/{filePath}'
}
},
karmaTarget: {
files: {
'karma.conf.js': 'karma.conf.js'
}
}
and in karma.conf.js
// ...
files: [
// include: "type": "js", "files": "app/**/*.spec.js", "ordering": "top-down"
]
// ...
Currently, there's a constant need to create a file with references to all typescript files, so that it could be globally included to determine types. This plugin works great for this, but needs a small enhancement to work properly.
This is the expected syntax and generated output. I've re-used html, as it seemed the closest and updated it with Typescript-specific things. Such comment is ignored by typescript compiler and allows for safe compilation.
/// <!-- include: "type": "ts", "files": "**/*.ts", "ordering": "top-down" -->
/// <reference path="../client/application/application.ts" />
/// <!-- /include -->
Basically to support TS, please update parsers and templates to this (note the "ts" at the end of each)
var parsers = {
'html': parseSource('HTML', /<!---?\s*include:\s+(.*)\s*-?--\s*>/gi),
'haml': parseSource('HAML', /-#\s+include:\s+(.*)/gi),
'jade': parseSource('JADE', /\/\/-?\s+include:\s+(.*)/gi),
'scss': parseSource('SASS', /\/\/\s+include:\s+(.*)/gi),
'ts': parseSource('TS', /\/\/\/\s<!---?\s*include:\s+(.*)\s*-?--\s*>/gi)
};
var endMarkerParsers = {
'html': findEndMarker('HTML', /<!---?\s*\/include\s+-?--\>/i),
'haml': findEndMarker('HAML', /-#\s+\/include/i),
'jade': findEndMarker('JADE', /\/\/-?\s+\/include/i),
'scss': findEndMarker('SASS', /\/\/\s+\/include/i),
'ts': findEndMarker('TS', /\/\/\/\s<!---?\s*\/include\s+-?--\>/i)
};
var templates = {
'html':
{
'js': '<script src="{filePath}"></script>',
'css': '<link href="{filePath}" rel="stylesheet" type="text/css">'
},
'haml':
{
'js': '%script{src: "{filePath}"}',
'css': '%link{href: "{filePath}", rel: "stylesheet", type: "text/css"}/'
},
'jade':
{
'js': 'script(src="{filePath}")',
'css': 'link(href="{filePath}", rel="stylesheet", type="text/css")'
},
'scss':
{
'scss': '@import "{filePath}";',
'css': '@import "{filePath}";'
},
'ts':
{
'ts': '/// <reference path="{filePath}" />'
}
};
Gruntfile config:
includeSource: {
options: {
basePath: 'app',
baseUrl: 'public/',
templates: {
less: {
less: '@import "{filePath}";',
css: '@import "{filePath}";'
}
}
},
app: {
files: {
'.tmp/index.html': 'app/index.tpl.html'
}
}
}
Index.html:
<!-- include: "type": "less", "files": "styles/**/*.less" -->
"grunt includeSource" produces:
TypeError: Cannot call method 'replace' of undefined node_modules\grunt-include-source\tasks\include_source.js:184:64
your_target: {
// Target-specific file lists and/or options go here.
files: {
'html/pages/*.html': 'html/pages/*.html'
}
}
So like this i could target all my html files and include all my css/js files.
If it is working already, how can i make my configs?
Best regards, Mário.
Hi, I have that code in my index.html file:
`
The output html on both serve:dist
and grunt build
not including the application.js file inside the generated html although it is been created in the .dist/scripts directory. All the files are being included using regular grunt serve
The weirdest thing is that if I put a script tag (any script tag) inside the include (between the include and /include) the application.js file is being included in the index.html.
Currently when using grunt-include-source and specifying same input and output files in the output file the comments <-- include etc --> are removed and therefore I have to use a tmp file to do code.
Would it be difficult if the comments weren't deleted every time the script runs ?
Hi! It seems your documentation has a bug: Instead of includePath you are using the option baseUrl in your code...
In certain cases, not studied exactly, but happens quite often, plugin strips last include block.
Guess, this happens when file contains more than one include blocks and plugin does a lot of changes.
Source file contains
<!-- build:js({.tmp,app}) /scripts/scripts.js -->
<!-- include: "type": "js", "files": "scripts/*.js" -->
<!-- /include -->
<!-- include: "type": "js", "files": "scripts/service/**/*.js" -->
<!-- /include -->
<!-- include: "type": "js", "files": "scripts/directives/**/*.js" -->
<!-- /include -->
<!-- include: "type": "js", "files": "scripts/controllers/**/*.js" -->
<!-- /include -->
<!-- include: "type": "js", "files": "modules/**/*.js" -->
<!-- /include -->
<!-- endbuild -->
Sometimes the very last block is getting rewritten as follows
<!-- /include -->
<script src="modules/core/core.js"></script>
<script src="modules/core/loader.js"></script>
<script src="modules/core/core.js"></script>
<script src="modules/core/loader.js"></script>
<!-- /include -->
I'll take a closer look in which case this happens, but it surely happens quite often, once in 3-4 days at least.
I am not getting all my files that are in the list.
basic settings:
includeSource:{
options:{},
app: {
files: {'src/test.html':'src/test.html'}
}
}
myFileList: {
js: [
'vendor/jquery/jquery.js',
'vendor/angular/angular.js',
'vendor/angular-animate/angular-animate.js',
'vendor/v-accordion/v-accordion.js',
'vendor/angular-growing-input/angular-grow.js',
'vendor/angular-cookies/angular-cookies.js',
'vendor/angular-ui-router/angular-ui-router.js',
'vendor/angularjs-datepicker/angular-datepicker.min.js',
'vendor/ng-csv/ng-csv.js',
'vendor/bootstrap/bootstrap.min.js',
'vendor/d3/d3.js',
'vendor_override/kendo-ui/kendo.all.min.js',
'vendor/moment/moment-with-locales.js',
'vendor/moment-timezone/moment-timezone-with-data.min.js',
'vendor/breeze-client/breeze.debug.js',
'vendor/breeze-client/breeze.min.js',
'vendor/breeze-client-labs/breeze.savequeuing.js',
'vendor/breeze-client/breeze.bridge.angular.js',
'vendor/breeze-client/breeze.ajax.angular.js',
'vendor_override/breeze-client-labs/breeze.directives.js'
]
}
test.html:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<!-- include: "type": "js", "files": "<%= myFileList.js %>" -->
<!-- /include -->
</head>
<body>
</body>
</html>
rendered:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<!-- include: "type": "js", "files": "<%= vendor_files.js %>" -->
<script src="vendor/angular/angular.js"></script>
<script src="vendor/angular-animate/angular-animate.js"></script>
<script src="vendor/angular-growing-input/angular-grow.js"></script>
<script src="vendor/angular-cookies/angular-cookies.js"></script>
<script src="vendor/d3/d3.js"></script>
<script src="vendor/breeze-client/breeze.debug.js"></script>
<script src="vendor/breeze-client-labs/breeze.savequeuing.js"></script>
<!-- /include -->
</head>
<body>
</body>
</html>
missing a number of file. What am I missing?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.