Class: WebpackDriver::Configuration
- Inherits:
-
Object
- Object
- WebpackDriver::Configuration
- Defined in:
- lib/webpack_driver/configuration.rb,
lib/webpack_driver/configuration/example.rb,
lib/webpack_driver/configuration/generated.rb
Defined Under Namespace
Constant Summary collapse
- ROOT =
Pathname.new(__FILE__).dirname.join('..', '..')
Instance Attribute Summary collapse
-
#cmd_line_flags ⇒ Object
Returns the value of attribute cmd_line_flags.
-
#compile_script ⇒ Object
Returns the value of attribute compile_script.
-
#directory ⇒ Object
Returns the value of attribute directory.
- #environment ⇒ Object
-
#file ⇒ Object
Returns the value of attribute file.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#output_path ⇒ Object
Returns the value of attribute output_path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#process ⇒ Object
readonly
Returns the value of attribute process.
-
#tmp_directory ⇒ Object
Returns the value of attribute tmp_directory.
Instance Method Summary collapse
- #flags ⇒ Object
- #gem_root ⇒ Object
- #generate! ⇒ Object
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #launch(development:) ⇒ Object
- #manifest_file ⇒ Object
- #present? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
27 28 29 30 31 32 33 34 35 |
# File 'lib/webpack_driver/configuration.rb', line 27 def initialize( = {}) .each { |k, v| send("#{k}=", v) } @file = Pathname.new(file) unless file.nil? @directory ||= Pathname.getwd @output_path ||= @directory.join('public', 'assets') @tmp_directory ||= @directory.join('tmp') @generated = Generated.new([], config: self) @generated.invoke_all end |
Instance Attribute Details
#cmd_line_flags ⇒ Object
Returns the value of attribute cmd_line_flags.
14 15 16 |
# File 'lib/webpack_driver/configuration.rb', line 14 def cmd_line_flags @cmd_line_flags end |
#compile_script ⇒ Object
Returns the value of attribute compile_script.
12 13 14 |
# File 'lib/webpack_driver/configuration.rb', line 12 def compile_script @compile_script end |
#directory ⇒ Object
Returns the value of attribute directory.
18 19 20 |
# File 'lib/webpack_driver/configuration.rb', line 18 def directory @directory end |
#environment ⇒ Object
53 54 55 |
# File 'lib/webpack_driver/configuration.rb', line 53 def environment @environment ||= { NODE_ENV: 'development' } end |
#file ⇒ Object
Returns the value of attribute file.
17 18 19 |
# File 'lib/webpack_driver/configuration.rb', line 17 def file @file end |
#logger ⇒ Object
Returns the value of attribute logger.
11 12 13 |
# File 'lib/webpack_driver/configuration.rb', line 11 def logger @logger end |
#output_path ⇒ Object
Returns the value of attribute output_path.
15 16 17 |
# File 'lib/webpack_driver/configuration.rb', line 15 def output_path @output_path end |
#port ⇒ Object
Returns the value of attribute port.
10 11 12 |
# File 'lib/webpack_driver/configuration.rb', line 10 def port @port end |
#process ⇒ Object (readonly)
Returns the value of attribute process.
21 22 23 |
# File 'lib/webpack_driver/configuration.rb', line 21 def process @process end |
#tmp_directory ⇒ Object
Returns the value of attribute tmp_directory.
13 14 15 |
# File 'lib/webpack_driver/configuration.rb', line 13 def tmp_directory @tmp_directory end |
Instance Method Details
#flags ⇒ Object
57 58 59 60 61 62 |
# File 'lib/webpack_driver/configuration.rb', line 57 def flags opts = ['--config', @generated.path.to_s] opts += ['--port', port] if port opts += cmd_line_flags if cmd_line_flags opts end |
#gem_root ⇒ Object
49 50 51 |
# File 'lib/webpack_driver/configuration.rb', line 49 def gem_root ROOT end |
#generate! ⇒ Object
41 42 43 |
# File 'lib/webpack_driver/configuration.rb', line 41 def generate! Example.new([], config: self).invoke_all end |
#launch(development:) ⇒ Object
68 69 70 71 |
# File 'lib/webpack_driver/configuration.rb', line 68 def launch(development:) raise "Already launched" unless @process.nil? @process = development ? DevServer.new(self) : Compile.new(self) end |
#manifest_file ⇒ Object
37 38 39 |
# File 'lib/webpack_driver/configuration.rb', line 37 def manifest_file output_path.join('manifiest.json') end |
#present? ⇒ Boolean
45 46 47 |
# File 'lib/webpack_driver/configuration.rb', line 45 def present? file.exist? end |