mklabs / node-build-script

MIT License
322 stars 55 forks source link

Javascript configuration and output #45

Closed getdave closed 12 years ago

getdave commented 12 years ago

I'm a little confused about how to figure the javascript. This is what I have in the grunt.js file.

    concat: {
      dist: {
        src: ['js/plugins.js', 'js/main.js'],
        dest: 'js/testing-3.0.2.js'
      }
    },
    min: {
      dist: {
        src: 'js/testing-3.0.2.js',
        dest: 'js/main.js'
      }
    },

This is what I have in my index.html file.

   <!-- build:js js/main.js -->
    <script src="js/plugins.js"></script>
    <script src="js/main.js"></script>
    <!-- endbuild -->

However, in the /publish dir the main.js file is a minified version of the original main.js file only (ie: it hasn't concat'd or minified the plugins.js file).

I've got sneaky suspicion this is something do with require.js and that I should be setting an option to disable this or something.

Any help much appreciated.

mklabs commented 12 years ago

I feel that you spent some time figuring this out, and struggled a bit making the build-script works for you. Sorry about that =/

I've got sneaky suspicion this is something do with require.js and that I should be setting an option to disable this or something.

If you don't have this snippet of code in your Gruntfile, https://github.com/h5bp/node-build-script/blob/master/tasks/init/h5bp/gruntfile.js#L115-119 the rjs task shouldn't interfere with your concat / min handling.

May I ask you the state of js/testing-3.0.2.js (dest of concat config) ? Is it the concataned version of these two files as expected ?

What happens if you slightly change the filename of your minified file js/main.js to js/main.min.js (in which case you'll need to update the html block comment too, to properly do the replacement) ?

I'll try tomorrow to reproduce your test case, and get this error of main.js minified without being concat'd to the plugin file. There must be something I have missed.


To let you know, we're currently considering to rework the overall process to be a bit easier, the idea is to parse the HTML markup thanks to these block comments to get back the list of assets to handle and optimize. All you would need to do is to adjust your HTML markup to wire up the list of JS / CSS files you'd like to be concat'd / minified / revved / replaced.

Right now, as you may have experienced, you need to keep these paths in sync (between HTML block comment <-- build:js js/main.js --> with the state of your concat / min config), and somehow match the result of concat / min to their <-- build:js path/to/new/file.js --> equivalents.

Would it make sense to you ?

getdave commented 12 years ago

Hi Mickael,

Your're correct I spent a bit of time getting frustrated with this.

However I understand that it's still a work in progress and I appreciate your efforts on this. I particular appreciate you replying so quickly.

Personally I think we just need to make the configuration of JS and CSS a lot simpler and more obvious.

I'm back in the office on Monday. I'll get back to you then.

Cheers

Dave

On 6 July 2012 20:37, Mickael Daniel < reply@reply.github.com

wrote:

I feel that you spent some time figuring this out, and struggled a bit making the build-script works for you. Sorry about that =/

I've got sneaky suspicion this is something do with require.js and that I should be setting an option to disable this or something.

If you don't have this snippet of code in your Gruntfile, https://github.com/h5bp/node-build-script/blob/master/tasks/init/h5bp/gruntfile.js#L115-119the rjs task shouldn't interfere with your concat / min handling.

May I ask you the state of js/testing-3.0.2.js (dest of concat config) ? Is it the concataned version of these two files as expected ?

What happens if you slightly change the filename of your minified file js/main.js to js/main.min.js (in which case you'll need to update the html block comment too, to properly do the replacement) ?

I'll try tomorrow to reproduce your test case, and get this error of main.js minified without being concat'd to the plugin file. There must be something I have missed.


To let you know, we're currently considering to rework the overall process to be a bit easier, the idea is to parse the HTML markup thanks to these block comments to get back the list of assets to handle and optimize. All you would need to do is to adjust your HTML markup to wire up the list of JS / CSS files you'd like to be concat'd / minified / revved / replaced.

Right now, as you may have experienced, you need to keep these paths in sync (between HTML block comment <-- build:js js/main.js --> with the state of your concat / min config), and somehow match the result of concat / min to their <-- build:js path/to/new/file.js --> equivalents.

Would it make sense to you ?


Reply to this email directly or view it on GitHub: https://github.com/h5bp/node-build-script/issues/45#issuecomment-6814375

getdave commented 12 years ago

Hi Mickael,

Just to let you know, following your instructions seems to have fixed the issue.

Again, I think making the configuration simpler and clearer would go a long way to getting more people using the script.

If you want to run anything by me let me know. I am however not a Node.js developer!

Thanks

mklabs commented 12 years ago

Great. Glad to know the few comments here have helped you.

You're right about the need to make the configuration simpler, at least a bit clearer.

The doc of the build script is managed through the project wiki, which is open to anyone to contribute and make it better. If you feel it, don't hesitate to add any piece of documentation you find useful / or would have helped you.