标签: grunt-includes

使用grunt自动将本地*.js和*.css文件引用到index.html中

我打算开发一个angularJS客户端,我将使用角度组件.这将导致多个.js / .css文件.为了避免手动引用每个新添加的js/css文件,我打算使用grunt-include-source任务.

问题是,在配置Gruntfile.js后,"grunt includeSource"任务运行,返回"Done,without errors."状态,但在index.html文件中没有更新.

我的项目结构是附图中显示的结构(我使用WebStorm作为IDE). 项目结构

我的index.html文件如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>RavenApp</title>
    <!-- include: "type": "css", "files": "*.css" -->
</head>
<body>
    <!-- bower:js -->
    <script src="../bower_components/angular/angular.js"></script>
    <script src="../bower_components/angular-route/angular-route.js"></script>
    <script src="../bower_components/angular-sanitize/angular-sanitize.js"></script>
    <script src="../bower_components/angular-mocks/angular-mocks.js"></script>
    <script src="../bower_components/jquery/dist/jquery.js"></script>
    <script src="../bower_components/underscore/underscore.js"></script>
    <!-- endbower -->

    <!-- include: "type": "js", "files": "*.js" -->
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我的Gruntfile.js如下:

module.exports = function (grunt) {
    grunt.loadNpmTasks('grunt-wiredep');
    grunt.loadNpmTasks('grunt-include-source');

    grunt.initConfig({
        wiredep: {
            target: {
                src: 'app/index.html'
            }
        },
        includeSource: {
            options: {
                basePath: 'app',
                templates: {
                    html: { …
Run Code Online (Sandbox Code Playgroud)

html javascript angularjs gruntjs grunt-includes

5
推荐指数
1
解决办法
551
查看次数

标签 统计

angularjs ×1

grunt-includes ×1

gruntjs ×1

html ×1

javascript ×1