GithubHelp home page GithubHelp logo

scott-laursen / grunt-scriptlinker Goto Github PK

View Code? Open in Web Editor NEW
21.0 2.0 34.0 20 KB

Grunt plugin for autoinsertion of script tags in an html file

License: MIT License

JavaScript 94.95% HTML 5.05%

grunt-scriptlinker's People

Contributors

kennethlynne avatar mikermcneil avatar scott-laursen avatar zolmeister avatar

Stargazers

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

Watchers

 avatar  avatar

grunt-scriptlinker's Issues

Feature: add/remove file with grunt watch

Instead of creating whole block we could setup grunt watch and listen to added or deleted event and add/remove script.

grunt.event.on('watch', function(action, filepath) {
  if(action == 'added'){
   //add script
  }
  if( action == 'deleted'){
   //remove script
  }
});

Add an option to strip out start/end tags from resulting file

I always kind of wanted this when I was inserting js/css files into my HTML file, but now that I'm trying to conditionalize our chrome extension's build, the file I'm trying to replace in is manifest.json. JSON doesn't allow for comments, so I need those start/end comment lines to be removed as well once the files get inserted. Since the resulting JSON file isn't valid, I can't JSON parse it (which my build does later on) and the chrome extension store won't accept it (I would have to manually remove the comment tags).

I have a pull request coming that has an option added. Feel free to give the option a better name or something.

appRoot doesn't work correctly if src files are under the appRoot

Here's my config:

    var javascriptLoadOrder = [
        'src/main/resources/vendor/**/*.js',
        'src/main/resources/app/js/Constants.js',
        'src/main/resources/app/js/Random.js',
        'src/main/resources/app/js/Vector.js',
        'src/main/resources/app/js/Resources.js',
        'src/main/resources/app/js/StatsData.js',
        'src/main/resources/**/*.js'
    ];

//...

        scriptlinker: {
            app: {
                options: {
                    startTag: '<!--SCRIPTS-->',
                    endTag: '<!--SCRIPTS END-->',
                    fileTmpl: '<script src="%s"></script>\n',
                    appRoot: 'src/main/generated'
                },
                src: javascriptLoadOrder,
                dest: 'src/main/generated/foo.html',
                cwd: '.',
                flatten: true

            }
        }

In the destination file, the javascript files have this path:

<script src="src/main/resources/vendor/js/jquery-2.0.2.min.js"></script>
<script src="src/main/resources/vendor/js/jquery-ui.js"></script>
<script src="src/main/resources/vendor/js/jquery.hammer.min.js"></script>
<script src="src/main/resources/vendor/js/lodash.min.js"></script>
<script src="src/main/resources/app/js/Constants.js"></script>
<script src="src/main/resources/app/js/Random.js"></script>

This is correct relative to the gruntfile, but that's not what I asked for. It seems to have ignored what I set appRoot to. Instead, they should look like this:

<script src="../resources/vendor/js/jquery-2.0.2.min.js" type="text/javascript"></script>
...

Or , maybe I'm just misunderstanding how to use the tool.

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.