Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Webpack + Yarn usage by simple new flag
rails_webpacker
With Rails 5.1, now Webpacker and Yarn are first class citizens. To accommodate, I propose those changes: - New Task "yarn", which installs both nodejs + yarn (inspired by other roles), to be run at provision stag - important yarn files are git-exported, node_modules + packs folder symlinked at deploy stage. Enable that behaviour with ``rails_webpacker: yes`` - yarn install is taken care of by rake asset:precompile in Rails 5.1 (https://github.com/rails/rails/blob/master/railties/lib/rails/tasks/yarn.rake). IMPORTANT: The app needs to have a binstub bin/yarn in the repo, otherwise nothing will happen. Run rails app:update:bin to add that.
- Loading branch information
Showing
10 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Nodejs + Yarn | ||
|
||
Intended to run during initial provisioning. | ||
|
||
```yaml | ||
- role: dresden-weekly.rails/yarn | ||
nodejs_version: 'nodejs-v6x' | ||
``` | ||
|
||
Installs Yarn + Nodejs via ppa/apt repository | ||
|
||
**NOTE**: If you want to use yarn, you also might want to enable yarn:install step during deployment, see [**rails/create-release**](https://github.com/dresden-weekly/ansible-rails/tree/develop/rails/create-release) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
nodejs_version: 'nodejs-v6x' | ||
|
||
nodejs_install: | ||
- build-essential | ||
|
||
nodejs_version_map: | ||
nodejs-v7x: '7.x' | ||
nodejs-v6x: '6.x' | ||
nodejs-v5x: '5.x' | ||
nodejs-v4x: '4.x' | ||
nodejs-v012: '0.12' | ||
nodejs-v010: '0.10' | ||
iojs-v3x: 'iojs_3.x' | ||
iojs-v2x: 'iojs_2.x' | ||
iojs-v1x: 'iojs_1.x' | ||
|
||
nodejs_dependencies: | ||
- curl | ||
|
||
yarn_repositories: | ||
- type: deb | ||
url: 'https://dl.yarnpkg.com/debian/ stable' | ||
component: main | ||
|
||
yarn_dependencies_pre: | ||
- apt-transport-https | ||
|
||
yarn_dependencies: | ||
- yarn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- include: 'nodejs.yml' | ||
- include: 'yarn.yml' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
- name: install dependencies | ||
apt: | ||
name: "{{ item }}" | ||
update_cache: true | ||
cache_valid_time: 3600 | ||
with_items: "{{ nodejs_dependencies }}" | ||
|
||
- name: install additional | ||
apt: | ||
name: "{{ item }}" | ||
with_items: "{{ nodejs_install }}" | ||
|
||
- name: add repository and install its signing key | ||
shell: curl -sL https://deb.nodesource.com/setup_{{ nodejs_version_map[nodejs_version] }} | bash - | ||
args: | ||
creates: /etc/apt/sources.list.d/nodesource.list | ||
|
||
- name: install nodejs | ||
apt: | ||
name: "{{ 'nodejs' if 'nodejs' in nodejs_version else 'iojs' }}" | ||
update_cache: true | ||
state: latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: Configure the Yarn APT key | ||
apt_key: url=https://dl.yarnpkg.com/debian/pubkey.gpg | ||
|
||
- name: Add Yarn repository | ||
apt_repository: | ||
repo: 'deb https://dl.yarnpkg.com/debian/ stable main' | ||
state: present | ||
|
||
- name: Install Yarn | ||
apt: pkg=yarn state=present | ||
|