Class: WebpackNative::ProdGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/webpack_native/prod_generator.rb

Instance Method Summary collapse

Instance Method Details

#generate_production_assetsObject

[View source]

3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/webpack_native/prod_generator.rb', line 3

def generate_production_assets
  compiling_notice = "Compiling for production..."
  puts "\n" + "\e[36m#{compiling_notice}\e[0m" + "\n\n"

  Mutex.new.synchronize do
    Dir.chdir "#{Rails.root}/app/webpack_native" do
      Dir.mkdir('src/images') unless Dir.exist?('src/images')
      %x{ yarn install }
      result = %x{ npm run build:prod }
      puts "\n"
      puts result
    end
  end
end