./lib/lux_assets/asset.rb in lux_assets-0.2.4 vs ./lib/lux_assets/asset.rb in lux_assets-0.2.9

- old
+ new

@@ -1,13 +1,14 @@ # Asset group, single asset that produces target css or js class LuxAssets::Asset def initialize ext, name - @ext = ext == :js ? :js : :css + raise ArgumentError.new('name not deinfed') if name.empty? + @ext = ext.to_sym == :js ? :js : :css @name = name.to_s - @files = LuxAssets.to_h[ext][@name] + @files = LuxAssets.to_h[@ext][@name] @target = "#{@ext}/#{@name}" end def js? @ext == :js @@ -24,11 +25,11 @@ for file in @files if file.is_a?(Proc) @data.push file.call else - @data.push LuxAssets::Element.new(file).compile + @data.push LuxAssets.compile file, production: true end end send 'compile_%s' % @ext @@ -76,18 +77,19 @@ end def compile_js save_data @data.join(";\n") do # babel fix and minify - LuxAssets::Cli.run 'node_modules/babel-cli/.bin/babel --minified --no-comments --compact true -o "%{file}" "%{file}"' % { file: @asset_path } + command = 'node_modules/babel-cli/.bin/babel --minified --no-comments --compact true -o "%{file}" "%{file}"' % { file: @asset_path } + LuxAssets::Cli.run command, message: "Babel filter and minify: #{@asset_path}" end end def compile_css save_data @data.join($/) do tag_public_assets #autoprefixer - LuxAssets::Cli.run './node_modules/.bin/autoprefixer-cli %s' % @asset_path + LuxAssets::Cli.run './node_modules/.bin/autoprefixer-cli %s' % @asset_path, message: "Autoprefixer: #{@asset_path}" end end end \ No newline at end of file