werkint/frontend-mapper-bundle

此包已被废弃,不再维护。未建议替代包。

此扩展包提供了gulp与Symfony2的集成

安装数: 1,114

依赖者: 1

建议者: 0

安全: 0

星标: 1

关注者: 5

分支: 0

开放问题: 0

语言:JavaScript

类型:symfony-bundle

v0.0.1 2016-01-06 12:45 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:48:24 UTC


README

requirejs.config({
    "config":      {
        "translatorLoader": {
            "domains": [{
                name:    'messages',
                locales: ['en', document.documentElement.lang],
            }]
        }
    },
});

将文件复制到项目: package.json

cd path/to/project
cp vendor/werkint/frontend-mapper-bundle/package.json ./

并运行npm install可能会有帮助:也可以运行npm install --save glob vendor/werkint/frontend-mapper-bundle/src/DependencyInjection/Compiler/JsmodelProviderPass.php

gulpfile.js

(function () {
    'use strict';

    process.env.NODE_MAX_LISTENER = 500;
    require('./vendor/werkint/frontend-mapper-bundle/src/Resources/gulp/index.js')();
})();

bower.json

touch app/config/bower.json
{
  "name": "brander-app",
  "version": "0.0.1",
  "authors": [
    "Someone <someone@gmail.com>"
  ],
  "ignore": [
    "**/.*"
  ],
  "resolutions": {
    "underscore": "~1.8.3",
    "backbone": "~1.1.2",
    "backbone.relational": "2f66cc5022"
  },
  "overrides": {
    "renames": {},
    "social": {
      "normalize": {
        "js/social": "*.js"
      }
    },
    "requirejs-domready": {
      "main": [
        "domReady.js"
      ]
    },
    "tabslet": {
      "main": [
        "jquery.tabslet.js"
      ]
    }
  }
}

常规配置

  1. 执行上面的行(创建gulpfile.js,运行npm install ...)

  2. 创建扩展依赖src/AppBundle/bower.json

    {
      "name": "sdelka-app",
      "main": [
        "bower.json"
      ],
      "dependencies": {
        "requirejs": "*",
        "jquery": "*",
        "lodash": "*",
        "backbone": "*",
        "backbone.relational": "*",
        "backbone.marionette": "*",
        "backbone.modelbinder": "*",
        "twig.js": "*",
        "backbone.radio": "*",
        "backbone.paginator": "*"
      }
    }
  3. 创建配置src/AppBundle/Resources/public/config.js

    (function () {
        'use strict';
    
        var config = window.require ? window.require : {};
        config = {
            'paths': config.paths,
    
            'waitSeconds': 30,
            'urlArgs':     'bust=' + window.$assets_version,
            "baseUrl": "/assets/js",
    
            "map":    {
    /*            "*":                   {
                    "twig":                  "config/twig",
                },
                "config/twig":         {
                    "twig": "twig",
                },
                "config/iwin-twitter": {
                    "social/module.twitter": "social/module.twitter",
                },*/
    
            },
    
            "shim": {
                "jquery.elastic": {
                    deps: ["jquery"]
                },
            },
    
            "config": {
                /*"social/api.google-loader":   window.$socials.google,*/
            },
        };
        
        require.config(config)
    }());
  4. 编辑app/Resources/views/base.html.twig

        <head>
            <meta charset="UTF-8" />
            <title>{% block title %}Welcome!{% endblock %}</title>
            {% block stylesheets %}{% endblock %}
            <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
            <!-- require -->
            <script src="{{ asset('assets/js/require.js') }}"></script>
            <!-- require config -->
            <script src="{{ asset('bundles/app/config.js') }}"></script>
        </head>
  5. 运行app/console as:ingulp

  6. 测试

requirejs(['jquery'], function ($) { alert($); })