Skip to content

Instantly share code, notes, and snippets.

@musaprg
Created September 26, 2018 02:54
Show Gist options
  • Save musaprg/7e611cc670dc8dde5a9cbe879326accf to your computer and use it in GitHub Desktop.
Save musaprg/7e611cc670dc8dde5a9cbe879326accf to your computer and use it in GitHub Desktop.
RailsとVueの環境構築

https://github.com/rails/webpacker#vue

Vue

To use Webpacker with Vue, create a new Rails 5.1+ app using --webpack=vue option:

# Rails 5.1+
rails new myapp --webpack=vue
(or run bundle exec rails webpacker:install:vue on a Rails app already setup with Webpacker).

The installer will add Vue and its required libraries using Yarn alongside automatically applying changes needed to the configuration files. An example component will be added to your project in app/javascript so that you can experiment with Vue right away.

If you're using Rails 5.2+ you'll need to enable unsafe-eval rule for your development environment. This can be done in the config/initializers/content_security_policy.rb with the following configuration:

  if Rails.env.development?
    policy.script_src :self, :https, :unsafe_eval
  else
    policy.script_src :self, :https
  end

You can read more about this in the Vue docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment