Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignoring files unneeded for building slug #95

Open
toddheslin opened this issue Feb 23, 2017 · 3 comments
Open

Ignoring files unneeded for building slug #95

toddheslin opened this issue Feb 23, 2017 · 3 comments

Comments

@toddheslin
Copy link

I've noticed the the slug can sometimes take a huge time to compile if the theme is using NPM modules. I'm personally using FoundationPress on my site and the NPM modules folder (including dev dependencies) is over 200MB.

I also don't want all of the wordpress themes included in the composer install (back to twentyeleven!)

Therefore in support/app_slug_compile.sh I have changed:

# Recursively copy files build final web dir
cp -R vendor/WordPress/WordPress/* tmp/public.building
cp -R public/* tmp/public.building

to

# Recursively copy files build final web dir
rsync -r --exclude=wp-content/themes vendor/WordPress/WordPress/* tmp/public.building
rsync -r --exclude=wp-content/themes/ridehacks-foundation/node_modules public/* tmp/public.building

Haven't noted any bugs here, and not sure if the rsync can be optimised. However just leaving this as an enhancement for peoples to try out.

Thanks for this awesome repo @xyu

@Tailzip
Copy link

Tailzip commented Feb 23, 2017

I wanted to get rid of WP default themes too! So, I updated support/app_slug_compile.sh, now it looks like this:

# ...

# Remove files to slim down slug if we're on Heroku
if [ ! -e .sluglocal ]
then
  rm -rf vendor/WordPress
  rm -rf public.built/wp-content/themes/twenty* # <- added this
  rm -rf public
fi

# ...

Also, regarding your huge theme folder, you can ignore files/folders added to the slug by adding them in .slugignorefile. Mine looks like this for example:

# Ignored Theme's Assets and Folders
**/node_modules/
**/package.json
**/.jshintrc
**/.jshintignore
**/gulpfile.js
**/ruleset.xml
**/.gitignore
**/bowerrc
**/.editorconfig

Hope this helps!

@toddheslin
Copy link
Author

Thanks @Tailzip I totally forgot to look at the if block below! Seems like the most logical way to do it.

I was under the impression that the .slugignore is specific to Heroku and not the local Vagrant setup. Maybe @xyu can clarify and make a decision on the right way to ignore these. I think your solution is better, unless the reloader daemon starts copying files to Vagrant before the remove takes place, causing more issues.

Not sure what is going on under the hood for this sync function.

@xyu
Copy link
Owner

xyu commented Feb 24, 2017

Yeah right now the rebuild script is pretty hacky, it should probably actually read .slugignore when building the public html dir seeing as that would make it more like production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants