File tree 3 files changed +32
-2
lines changed
examples/styled-components
3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < title > Webpack App</ title >
6
+ < meta http-equiv ="Content-Security-Policy " content ="default-src http: ">
7
+ </ head >
8
+ < body >
9
+ </ body >
10
+ </ html >
Original file line number Diff line number Diff line change @@ -27,5 +27,11 @@ module.exports = {
27
27
) ,
28
28
} ,
29
29
} ,
30
- plugins : [ new HtmlWebpackPlugin ( ) , new webpack . NamedModulesPlugin ( ) ] ,
30
+ plugins : [
31
+ new HtmlWebpackPlugin ( {
32
+ // uncomment this line to test RHL in "secure" env
33
+ // template: "index_csp.html",
34
+ } ) ,
35
+ new webpack . NamedModulesPlugin ( ) ,
36
+ ] ,
31
37
}
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- if ( ! module . hot || process . env . NODE_ENV === 'production' ) {
3
+ let evalAllowed = false ;
4
+ try {
5
+ eval ( 'evalAllowed = true' ) ;
6
+ } catch ( e ) {
7
+ // eval not allowed due to CSP
8
+ }
9
+
10
+ // RHL needs setPrototypeOf to operate Component inheritance, and eval to patch methods
11
+ const platformSupported = ! ! Object . setPrototypeOf && evalAllowed ;
12
+
13
+ if ( ! module . hot || process . env . NODE_ENV === 'production' || ! platformSupported ) {
14
+ if ( module . hot ) {
15
+ // we are not in prod mode, but RHL could not be activated
16
+ console . warn ( 'React-Hot-Loaded is not supported in this environment' ) ;
17
+ }
4
18
module . exports = require ( './dist/react-hot-loader.production.min.js' ) ;
5
19
} else {
6
20
module . exports = require ( './dist/react-hot-loader.development.js' ) ;
You can’t perform that action at this time.
0 commit comments