File tree 1 file changed +6
-21
lines changed
1 file changed +6
-21
lines changed Original file line number Diff line number Diff line change 3
3
module Snowpacker
4
4
module Rails
5
5
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
23
7
def compile
24
- snowpacker_command ( :build )
8
+ snowpacker_command ( env : :production , cmd : :build )
25
9
end
26
10
11
+ # Serve for development
27
12
def serve
28
- snowpacker_command ( :dev )
13
+ snowpacker_command ( env : :development , cmd : :dev )
29
14
end
30
15
31
16
private
32
17
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 ( ' ' ) } "
35
20
output = exec ( command )
36
21
end
37
22
end
You can’t perform that action at this time.
0 commit comments