class WebpackNative::InstallGenerator
Public Instance Methods
add_node_modules_to_gitignore()
click to toggle source
# File lib/generators/webpack_native/install_generator.rb, line 43 def add_node_modules_to_gitignore puts "\nAdding /app/webpack_native/node_modules to .gitignore...\n" folder_to_ignore = '/app/webpack_native/node_modules' # add webpack_native's node_modules folder to gitignore if it isn't added yet %x{ grep -qxF '#{folder_to_ignore}' .gitignore || echo '#{folder_to_ignore}' >> .gitignore } puts "=> Done!" end
add_webpack_native_folder()
click to toggle source
(1) we copy webpack_native folder into Rails /app folder
# File lib/generators/webpack_native/install_generator.rb, line 11 def add_webpack_native_folder directory 'webpack_native', 'app/webpack_native' # Not sure but using the gem from rubygems... seems like the "images" directory isn't created when this generator runs, in the meantime let's add it (once again maybe?) images_directory = 'app/webpack_native/src/images' empty_directory(images_directory) unless Dir.exist?(images_directory) end
output_installation_finished_msg()
click to toggle source
# File lib/generators/webpack_native/install_generator.rb, line 51 def output_installation_finished_msg puts "\n\e[32m*** WebpackNative - installation finished. ***\e[0m\n" end
run_npm_install()
click to toggle source
(3) run 'npm install' inside app/webpack_native folder to install the base modules
# File lib/generators/webpack_native/install_generator.rb, line 30 def run_npm_install install_notice = "\n||==>> Installing Node Modules... \n" wait_notice = "** This can take a while. Please be patient!\n\n" puts "\e[36m#{install_notice}\e[0m" # colorize output in cyan puts "\e[33m#{wait_notice}\e[0m" # colorize output in brown # more colors can be found at: https://stackoverflow.com/questions/1489183/colorized-ruby-output-to-the-terminal Dir.chdir "#{Rails.root}/app/webpack_native" do %x{ yarn install } # 88% + 80% faster than npm install end end