File tree Expand file tree Collapse file tree 4 files changed +2
-26
lines changed
Expand file tree Collapse file tree 4 files changed +2
-26
lines changed Original file line number Diff line number Diff line change 2727< script type ="text/javascript " data-csp ="ok ">
2828 // See commit this code was added in for an explanation.
2929 ( function ( ) {
30- const hashedIndexJs = ( window . sumaDynamicEnv || { } ) . VITE_HASHED_INDEX_JS ;
30+ const hashedIndexJs = ( document . querySelector ( 'script[src*="assets/index"]' ) || { } ) . src
3131 if ( ! hashedIndexJs ) {
3232 return ;
3333 }
Original file line number Diff line number Diff line change @@ -48,19 +48,6 @@ def emplace(keys_and_values)
4848
4949 protected def prepare
5050 return if File . exist? ( @index_html_backup )
51-
52- # Parse the manifest so we can get the hashed index JS path for further index.html templating.
53- begin
54- File . open ( Pathname . new ( @index_html_path ) . dirname + ".vite" + "manifest.json" ) do |f |
55- @manifest = Yajl ::Parser . parse ( f )
56- if ( hashed_js = @manifest . dig ( "index.html" , "file" ) )
57- @additional_kvps [ "VITE_HASHED_INDEX_JS" ] = hashed_js
58- end
59- end
60- rescue Errno ::ENOENT
61- # Ignore missing manifest
62- end
63-
6451 FileUtils . move ( @index_html_path , @index_html_backup )
6552 end
6653
Original file line number Diff line number Diff line change 22
33require "rack/dynamic_config_writer"
44
5- # rubocop:disable Layout/LineLength
65RSpec . describe Rack ::DynamicConfigWriter do
76 include_context "uses temp dir"
87
6463 dcw . emplace ( { } )
6564 expect ( File . read ( index ) ) . to eq ( "<html><head><script>globals.x={}</script></head><body></body></html>" )
6665 end
67-
68- it "includes the build JS asset file path from the manifest" do
69- File . write ( index , "" )
70- File . write ( manifest , { "index.html" => { "file" => "assets/index-C5Z8u35m.js" } } . to_json )
71-
72- dcw = described_class . new ( index , global_assign : "globals.x" )
73- dcw . emplace ( { } )
74- expect ( File . read ( index ) ) . to eq ( "<html><head><script>globals.x={\" VITE_HASHED_INDEX_JS\" :\" assets/index-C5Z8u35m.js\" }</script></head><body></body></html>" )
75- end
7666 end
7767
7868 describe "pick_env" do
8676 end
8777 end
8878end
89- # rubocop:enable Layout/LineLength
Original file line number Diff line number Diff line change 5151< script type ="text/javascript " data-csp ="ok ">
5252 // See commit this code was added in for an explanation.
5353 ( function ( ) {
54- const hashedIndexJs = ( window . sumaDynamicEnv || { } ) . VITE_HASHED_INDEX_JS ;
54+ const hashedIndexJs = ( document . querySelector ( 'script[src*="assets/index"]' ) || { } ) . src
5555 if ( ! hashedIndexJs ) {
5656 return ;
5757 }
You can’t perform that action at this time.
0 commit comments