Class: WebpackDriver::Configuration::Example

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/webpack_driver/configuration/example.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#yarnObject (readonly)

Returns the value of attribute yarn.



13
14
15
# File 'lib/webpack_driver/configuration/example.rb', line 13

def yarn
  @yarn
end

Class Method Details

.source_rootObject



15
16
17
18
# File 'lib/webpack_driver/configuration/example.rb', line 15

def self.source_root
    Pathname.new(__FILE__)
            .dirname.join('..', '..', '..', 'templates')
end

Instance Method Details

#generateObject



36
37
38
39
# File 'lib/webpack_driver/configuration/example.rb', line 36

def generate
    template("webpack.config.js", verbose: false)
    template("index.js", verbose: false, force: true)
end

#install_using_yarnObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/webpack_driver/configuration/example.rb', line 25

def install_using_yarn
    yarn.init unless yarn.valid?
    %w(webpack webpack-dev-server).each do |package|
        package = Knitter::Package.new(package, yarn: yarn)
        unless package.installed?
            package.dependency_type = :development
            package.add
        end
    end
end

#set_destination_rootObject



20
21
22
23
# File 'lib/webpack_driver/configuration/example.rb', line 20

def set_destination_root
    self.destination_root = options[:config].file.dirname
    @yarn = Knitter::Yarn.new(destination_root)
end