简体   繁体   中英

Merge all files (CSS, JS, HTML) to one HTML with Grunt

I have a specific project where all of the code (CSS, JS (Angular), HTML) must be in one giant HTML. I could manually copy all CSS and JS to index.hml but it is time consuming and prone to errors.

For some project I already use Grunt, so I was trying to use grunt-contrib-concat but it only merges files one under another. This doesn't really helps me, because the CSS should be in the sytle section in the header of the HTML, JS in the script section.

I read help on the github page, but there is no obvious solution.

I call the contac function like this:

 concat: {
    options: {
      separator: ';',
    },
    dist: {
      src: ['<%= yeoman.app %>/index.html', '<%= yeoman.app %>/styles/main.css', '<%= yeoman.app %>scripts/outro.js'],
      dest: 'dist/index.html',
    }
  }

This is only a test, and the result is not good for me.

Are here any place holders to tell the concat where to insert specific files?

In grunt we have a plugin

grunt.loadNpmTasks('grunt-contrib-concat');

This plugin concats all files which you specify.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM