Javascript Grunt将外部JS编译成内联HTML

Javascript Grunt将外部JS编译成内联HTML,javascript,html,gruntjs,Javascript,Html,Gruntjs,一旦构建了应用程序,是否可以从外部JS文件中获取代码,然后将其内联粘贴到脚本标记中(在index.html中) 例如,下面的两个文件都是相同的,但我希望JS在src/dir中外部实现,在build/dir中内联实现: src/index.html <head> <script src="long/minified/code.js"></script> </head> <head> <script> // l

一旦构建了应用程序,是否可以从外部JS文件中获取代码,然后将其内联粘贴到脚本标记中(在index.html中)

例如,下面的两个文件都是相同的,但我希望JS在src/dir中外部实现,在build/dir中内联实现:

src/index.html

<head>
  <script src="long/minified/code.js"></script>
</head>
<head>
  <script>
    // long... minified code to be added inline here
  </script>
</head>
Grunfile.js

grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
        dist: {
            src: [
                'long/minified/code.js',

                  ],
            dest: 'build/index.html',
         }
});
有可能我已经完全离开了,需要类似的东西,您可以使用它轻松地插入您的纸条:

HTML

grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
        dist: {
            src: [
                'long/minified/code.js',

                  ],
            dest: 'build/index.html',
         }
});
<head>
<!-- build:js inline -->
<script src="long/minified/code.js"></script>
<!-- /build -->
</head>
grunt.initConfig({
  processhtml: {
    dist: {
      files: {
        'build/index.html': ['src/index.html']
      }
    }
  }
});