Skip to content

Commit

Permalink
feat: add a mount directory configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
KonnorRogers committed Jul 24, 2020
1 parent 607ef29 commit c8556d7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/railsapp/config/initializers/snowpacker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Where to find the config file
snowpacker.config_file = Rails.root.join('config', 'snowpack.config.js')

# Snowpacker will set these values at runtime via `config/snowpack.config.js`
snowpacker.mount_dir = Rails.root.join('app', 'javascript')
snowpacker.output_path = "snowpacks" # => /public/snowpacks
snowpacker.port = "4035"

Expand Down
5 changes: 3 additions & 2 deletions examples/railsapp/config/snowpack.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const output_path = process.env["SNOWPACKER_OUTPUT_PATH"]
const port = process.env["SNOWPACKER_PORT"]
const mount_dir = process.env["SNOWPACKER_MOUNT_DIR"]

// not currently supported
// not currently supported as of v2.6.4
// const hostname = process.env["SNOWPACKER_HOSTNAME"]

const scripts = {
"mount:web_modules": `mount web_modules --to /${output_path}`,
"mount:__snowpack__": `mount __snowpack__ --to /${output_path}`,
"mount:snowpacks": `mount app/javascript --to /${output_path}`
"mount:snowpacks": `mount ${mount_dir} --to /${output_path}`
}

const installOptions = {
Expand Down
3 changes: 2 additions & 1 deletion lib/snowpacker/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module Snowpacker
class Configuration
attr_accessor :config_file

attr_accessor :mount_dir
attr_accessor :output_path
attr_accessor :port, :hostname

def initialize
@output_path = "snowpacks"
@mount_dir = File.join("app", "javascript")
@port = "4035"
@hostname = "localhost"
end
Expand Down
1 change: 1 addition & 0 deletions lib/snowpacker/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def set_env_variables
set_env("OUTPUT_PATH", Snowpacker.config.output_path)
set_env("HOSTNAME", Snowpacker.config.hostname)
set_env("PORT", Snowpacker.config.port)
set_env("MOUNT_DIR", Snowpacker.config.mount_dir)
end

private
Expand Down
3 changes: 2 additions & 1 deletion lib/snowpacker/templates/snowpack.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const output_path = process.env["SNOWPACKER_OUTPUT_PATH"]
const port = process.env["SNOWPACKER_PORT"]
const mount_dir = process.env["SNOWPACKER_MOUNT_DIR"]

// not currently supported
// const hostname = process.env["SNOWPACKER_HOSTNAME"]

const scripts = {
"mount:web_modules": `mount web_modules --to /${output_path}`,
"mount:__snowpack__": `mount __snowpack__ --to /${output_path}`,
"mount:snowpacks": `mount app/javascript --to /${output_path}`
"mount:snowpacks": `mount ${mount_dir} --to /${output_path}`
}

const installOptions = {
Expand Down
1 change: 1 addition & 0 deletions lib/snowpacker/templates/snowpacker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Where to find the config file
snowpacker.config_file = Rails.root.join('config', 'snowpack.config.js')

snowpacker.mount_dir = File.join('app', 'javascript')
snowpacker.output_path = "snowpacks" # => /public/snowpacks
snowpacker.port = "4035"

Expand Down

0 comments on commit c8556d7

Please sign in to comment.