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.
25 26 27 28 29 30 31 32 33 |
# File 'lib/webpack_driver/configuration.rb', line 25 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
51 52 53 |
# File 'lib/webpack_driver/configuration.rb', line 51 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
55 56 57 58 59 60 |
# File 'lib/webpack_driver/configuration.rb', line 55 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
47 48 49 |
# File 'lib/webpack_driver/configuration.rb', line 47 def gem_root ROOT end |
#generate! ⇒ Object
39 40 41 |
# File 'lib/webpack_driver/configuration.rb', line 39 def generate! Example.new([], config: self).invoke_all end |
#launch(development:) ⇒ Object
66 67 68 69 |
# File 'lib/webpack_driver/configuration.rb', line 66 def launch(development:) raise "Already launched" unless @process.nil? @process = development ? DevServer.new(self) : Compile.new(self) end |
#manifest_file ⇒ Object
35 36 37 |
# File 'lib/webpack_driver/configuration.rb', line 35 def manifest_file output_path.join('manifiest.json') end |
#present? ⇒ Boolean
43 44 45 |
# File 'lib/webpack_driver/configuration.rb', line 43 def present? file.exist? end |