<commit_before>namespace :webpacker do
  namespace :install do
    desc "Install everything needed for Vue"
    task :vue do
      config_path = Rails.root.join('config/webpack/shared.js')

      config = begin
        File.read(config_path)
      rescue Errno::ENOENT
        puts 'Webpack config not found. Make sure webpacker:install' \
        ' is run successfully before installing vue'
        exit!
      end

      # Module resolution https://webpack.js.org/concepts/module-resolution/
      if config.include?("'vue$':'vue/dist/vue.common.js'")
        puts "Couldn't automatically update module resolution in #{config_path}. Please set resolve { alias:{ 'vue$':'vue/dist/vue.common.js' } }."
      else
        config.gsub!(/resolve:(\s*\{)(\s*)extensions/,"resolve:\\1\\2alias: { 'vue$':'vue/dist/vue.common.js' },\\2extensions")
      end

      if config.include?("loader: 'url-loader?mimetype=image/png'")
        puts "Couldn't automatically update url-loader in #{config_path}. Please set { test: /\.png$/, loader: 'url-loader?mimetype=image/png' }."
      else
        config.gsub!(/module:(\s*\{)(\s*)rules:(\s*)\[/,"module:\\1\\2rules:\\3[\\2  { test: /\.png$/, loader: 'url-loader?mimetype=image/png'},")
      end

      if config.include?("loader: 'vue-loader',")<commit_msg>Start using ES Module build of Vue<commit_after>namespace :webpacker do
  namespace :install do
    desc "Install everything needed for Vue"
    task :vue do
      config_path = Rails.root.join('config/webpack/shared.js')

      config = begin
        File.read(config_path)
      rescue Errno::ENOENT
        puts 'Webpack config not found. Make sure webpacker:install' \
        ' is run successfully before installing vue'
        exit!
      end

      # Module resolution https://webpack.js.org/concepts/module-resolution/
      if config.include?("'vue$':'vue/dist/vue.esm.js'")
        puts "Couldn't automatically update module resolution in #{config_path}. Please set resolve { alias:{ 'vue$':'vue/dist/vue.esm.js' } }."
      else
        config.gsub!(/resolve:(\s*\{)(\s*)extensions/,"resolve:\\1\\2alias: { 'vue$':'vue/dist/vue.esm.js' },\\2extensions")
      end

      if config.include?("loader: 'url-loader?mimetype=image/png'")
        puts "Couldn't automatically update url-loader in #{config_path}. Please set { test: /\.png$/, loader: 'url-loader?mimetype=image/png' }."
      else
        config.gsub!(/module:(\s*\{)(\s*)rules:(\s*)\[/,"module:\\1\\2rules:\\3[\\2  { test: /\.png$/, loader: 'url-loader?mimetype=image/png'},")
      end

      if config.include?("loader: 'vue-loader',")
{'fraction_non_alphanumeric': 0.17331288343558282, 'fraction_numerical': 0.005368098159509203, 'mean_word_length': 2.9351432880844643, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2987252', 'n_tokens_mistral': 861, 'n_tokens_neox': 835, 'n_words': 179}