Skip to content

Commit 5f97e9a

Browse files
committed
feat: have the runner specify a node_env
1 parent 5a3120b commit 5f97e9a

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

lib/snowpacker/rails/runner.rb

+6-21
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,20 @@
33
module Snowpacker
44
module Rails
55
class Runner
6-
def self.from_command_line(args)
7-
return from_config if args.empty?
8-
new(args)
9-
end
10-
11-
def self.from_config
12-
to_args(::Rails.application.config.snowpacker)
13-
end
14-
15-
def self.to_args(config)
16-
new([*config.entry_points, '--out', config.destination])
17-
end
18-
19-
def initialize(args)
20-
@args = args
21-
end
22-
6+
# Build for production
237
def compile
24-
snowpacker_command(:build)
8+
snowpacker_command(env: :production, cmd: :build)
259
end
2610

11+
# Serve for development
2712
def serve
28-
snowpacker_command(:dev)
13+
snowpacker_command(env: :development, cmd: :dev)
2914
end
3015

3116
private
3217

33-
def snowpacker_command(cmd = '')
34-
command = "yarn run snowpack #{cmd} #{@args.join(' ')}"
18+
def snowpacker_command(*args, env: '', cmd: '')
19+
command = "NODE_ENV=#{env} yarn run snowpack #{cmd} #{args.flatten.join(' ')}"
3520
output = exec(command)
3621
end
3722
end

0 commit comments

Comments
 (0)