简体   繁体   English

如何模块化Yeoman + Bootstrap + Sass生成器?

[英]How can I modularize the Yeoman + Bootstrap + Sass generator?

I am using Yeoman to auto-generate a project using Bootstrap & Sass. 我正在使用Yeoman使用Bootstrap&Sass自动生成项目。 The one thing I am having trouble with is changing the default structure of the project to be more modularized. 我遇到的一件事是将项目的默认结构更改为更加模块化。 The generator is here on GitHub.com 发电机是这里的GitHub.com

Currently the application is structured like so: 当前,应用程序的结构如下:

/app
    /images/
    /scripts/
        /controllers/
            main.js
        app.js
    /styles/
        main.css
    /views/
        main.html
index.html

I'd rather have it separated into individual directives with a core(shared) folder, so that it would be like so: 我宁愿将它与带有core(shared)文件夹的单独指令分开,这样就可以了:

/app/
    /directives/
        /home/
           home.html
           homeCtrl.js
           home.sass
index.html
app.module.js
app.route.js

But I am having difficulty figuring out the best method of modularizing the project. 但是我很难找出使项目模块化的最佳方法。 Am I supposed to be creating the file structure that I want with the pre-generated application, and then edit it within the Gruntfile.js? 我是否应该使用预生成的应用程序创建所需的文件结构,然后在Gruntfile.js中对其进行编辑? Is there a more streamlined way of doing this, or am I SOL doing it manually? 是否有更简化的方法来执行此操作,或者我是SOL手动执行此操作?

The best and elegant way is to follow their guideline around creating a customised template which you can use to generate apps based on it. 最好,最优雅的方法是遵循他们的指导方针来创建自定义模板,您可以使用该模板来基于模板生成应用程序。

However, if this is a one off thing you probably won't need to bother unless you want to create something decent and share it with community, so other people can use your template and create their app with modularised structure. 但是,如果这是一次性的事情,那么除非您想创建一些像样的东西并与社区共享,否则您可能无需费心,其他人可以使用您的模板并使用modularised结构来创建他们的应用程序。

Even if you don't try to write your own template you can still read the guide and modify the initial template generator to change the file structure before creating the app for you. 即使您不尝试编写自己的模板,也可以在为您创建应用程序之前阅读指南并修改初始模板生成器以更改文件结构。

Here is another good article around template customisation: 这是关于模板定制的另一篇好文章:

https://scotch.io/tutorials/create-a-custom-yeoman-generator-in-4-easy-steps https://scotch.io/tutorials/create-a-custom-yeoman-generator-in-4-easy-steps

This project appears to be abandoned. 该项目似乎被放弃了。 The most recent change is a year ago, there are 67 issues and 18 pull requests. 最近的更改是在一年前,有67个问题和18个请求请求。 It's probably only generating Angular 1.x code as well, and that may not be "up to date" with current Angular 1 best practices. 它可能也只生成Angular 1.x代码,并且可能不是最新的Angular 1最佳实践的“最新”。

You can, of course, fork the project and make changes yourself, and even take over maintenance of it, but you might be better to look at something like Angular-cli, which generates Angular2 code, and is being actively developed. 当然,您可以分叉项目并自己进行更改,甚至可以接管它的维护,但是最好看看Angular-cli之类的东西,它会生成Angular2代码并正在积极开发中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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