Giter VIP home page Giter VIP logo

rails6-trailblazer's Introduction

Cấu hình rails webpack

https://evilmartians.com/chronicles/evil-front-part-1

https://evilmartians.com/chronicles/evil-front-part-2

https://evilmartians.com/chronicles/evil-front-part-3

Trailblazer

https://github.com/trailblazer/trailblazer

Install gems:

gem 'trailblazer', '2.0.7'
gem 'trailblazer-rails', '1.0.8'
gem 'trailblazer-cells', '0.0.3'
gem 'cells-slim', '0.0.5'
gem 'cells-rails', '0.0.8'

Chạy ứng dụng

Procfile: Dùng để chạy các lệnh start Server. Run comand: hivemind

bin/webpack-dev-server: Start server webpack

rails s: Start server rails

rails g component <component> dùng để tạo ra components (js, css, html)

rails g traiblazer <component> dùng để tạo ra components và các file liên quan đến cấu trúc trailblazer (controller, concepts, contract)

rails trailblazer:rm <component> dùng để xoá các components và các file liên quan đến cấu trúc traiblazer (Rollback)

Cài đặt plugin

ERB: bundle exec rails webpacker:install:erb

Coffee:: bundle exec rails webpacker:install:coffee

Hoặc yarn add <plugin>

Cấu trúc thư mục

Controller -> call views -> load components

controller: Chỉ để điều hướng và trả kết quả ra views

operation: Xử lý logic

contract: Validate tâng params

views: Chỉ có file html theo các action và load các partial từ components. Có thể dùng Cell

components: Chứa các file js, css, images, partial. Path: frontend/components/

eslintrc

Nếu dùng biến toàn cục thì bổ sung vào file eslintrc biến toàn cục đó

"env": {
    "browser": true,
    "jquery": true,
    "Routes": true
  },

Bug

  1. Bị nhấp nháy khi render ra view. Lý do trong quá trình build thì không build ra file css, mà css được load bởi javascript. Khắc phục: Trong file webpacker.yml sửa dòng extract_css: true thành extract_css: false

Branch

Branch master: Vẫn giữ nguyên cấu trúc của Rails và cấu hình Webpack

Branch config_traiblazer: Thay đổi cấu trúc từ Rails sang Trailblazer và cấu hình webpack. Được merge từ nhánh master

rails6-trailblazer's People

Contributors

rubykachu avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.