Giter Site home page Giter Site logo

grunt-include-source's People

Contributors

adityav avatar craigceleste avatar danic89 avatar danielnicinskidev avatar igorsadovskiy avatar isadovskiy avatar jchlapinski avatar jwvdiermen avatar mattzeunert avatar mdaverde avatar mgierw avatar ondrasak avatar paulbdavis avatar pchorus avatar sjors avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-include-source's Issues

Line break issue in Windows with wiredep

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.

Warning: Symbol is not defined Use --force to continue.

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

  • includeSource

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

  • jshint

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

  • clean

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

  • nodeunit

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

  • lineending
    Loading "Gruntfile.js" tasks...OK
  • default, test

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.

Ordering doesn't work

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'
            }
        }
    }

Readme typo ('template' ---> 'templates')

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!

Overwrite not working

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

Does nothing

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!

Exclude paths

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...

missing extendr dependancy

Loading "include_source.js" tasks...ERROR

Error: Cannot find module 'extendr'

installing extendr module by "npm install extendr --save-dev" resolved the problem

type="text/javascript" is redundant

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.

why not include sources???

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

How to use with yeoman when I do `grunt server`

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 ?

Adding support for JSP files

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:

  • parsers added a row: 'jsp': parseSource('HTML', /<!---?\sinclude:([\s\S]?)-?--\s*>/gi)
  • endMarkerParsers added a row: 'jsp': findEndMarker('HTML', /<!---?\s*/include\s+-?-->/i)
  • templates added a row:
    'jsp':{
    'js': '<script type="text/javascript" src="{filePath}"></script>',
    'css': ''
    }
    And it worked! Need to point out that I use the HTML syntax in this JSP file.

Include sources in js files

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"
]
// ...

Please support TypeScript template

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}" />'
        }
    };

type: less produces "Cannot call method 'replace' of undefined"

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

[Question] Targets, could be a folder and not a file

@jwvdiermen,

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.

script tag not included in html

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.

Include sources in the same file

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 ?

Stip of the last <include> block header when writing deps to the same file

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.

Fails to include all files in <%= myFileList.js %>

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.