lib/texture_packer/cli.rb in texture_packer-1.4.1 vs lib/texture_packer/cli.rb in texture_packer-1.5.0

- old
+ new

@@ -36,17 +36,21 @@ exec_cmd('pngquant', "#{path}.png", '--force') end end def create_packer - has_mobile = true if File.exists?('packed_m.css') + split_type = case + when File.exists?('packed_m.css') ; TexturePacker::SPLIT_BY_MOBILE + when File.exists?('packed_tw.css') ; TexturePacker::SPLIT_I18N + else ; nil + end # 由路徑計算 class 名字 dir_name = File.expand_path(Dir.pwd).gsub(/.*\/Texture-Packer\/.*?\/(.*)/, '\1') content = output_paths_mapping.map{|_, path| File.read("#{path}.css") }.join - return TexturePacker.new(dir_name, output_paths_mapping, content, has_mobile) + return TexturePacker.new(dir_name, output_paths_mapping, content, split_type) end def output_paths_mapping @output_paths_mapping ||= begin Dir['*.css'].map do |path| @@ -59,10 +63,10 @@ # ---------------------------------------------------------------- # ● 自動輸出到專案 # ---------------------------------------------------------------- def write_to_project_dir!(packer, output1, output2) css_pre_lines = ["@import './mixin.scss';"] - css_pre_lines.unshift("@import 'global_mixins';") if packer.has_mobile + css_pre_lines.unshift("@import 'global_mixins';") if packer.need_global_mixins? sub_dirs = packer.dir_name.split(File::Separator)[0...-1] project_assets_path = Pathname.new(@options.project_dir).join('app', 'assets') css_path = project_assets_path.join('stylesheets', 'packed_sprites', *sub_dirs, packer.dir_without_theme)