File tree Expand file tree Collapse file tree 4 files changed +16
-6
lines changed
Expand file tree Collapse file tree 4 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,8 @@ $ preact build
104104 --src Entry file (index.js). [default: " src" ]
105105 --dest Directory root for output. [default: " build" ]
106106 --production, -p Create a minified production build. [default: true]
107- --no-prerender Disable pre-render of static app content.
107+ --no-prerender Disable pre-render of static app content.
108+ --service-worker Add a service worker to application. [default: true]
108109 --prerenderUrls Path to pre-render routes configuration. [default " prerender-urls.json" ]
109110 --template Path to template file.
110111 --clean Clear output directory before building. [default: true]
@@ -133,16 +134,16 @@ $ preact serve
133134
134135### Templates
135136
136- ### Full:
137+ ### Full:
137138
138139- Preact Router Included
139140- Dynamic routes
140141
141142<a href =" https://build-gqqxvrjtbx.now.sh/ " target =" _blank " >Demo</a >
142143
143- ### Simple:
144+ ### Simple:
144145
145- - Github API
146+ - Github API
146147<a href =" https://build-xsepqcgvue.now.sh/ " target =" _blank " >Demo</a >
147148
148149### Empty
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ export default asyncCommand({
3131 description : 'Path to pre-render routes configuration.' ,
3232 default : 'prerender-urls.json'
3333 } ,
34+ 'service-worker' : {
35+ description : 'Add a service worker to the application.' ,
36+ default : true
37+ } ,
3438 clean : {
3539 description : 'Clear output directory before building.' ,
3640 default : true
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ if (process.env.NODE_ENV==='development') {
44 // enable preact devtools
55 require ( 'preact/devtools' ) ;
66}
7- else if ( 'serviceWorker' in navigator && location . protocol === 'https:' ) {
7+ else if ( process . env . ADD_SW && 'serviceWorker' in navigator && location . protocol === 'https:' ) {
88 navigator . serviceWorker . register ( '/sw.js' ) ;
99}
1010
Original file line number Diff line number Diff line change @@ -199,7 +199,12 @@ const production = config => addPlugins([
199199 / p u s h - m a n i f e s t \. j s o n $ / ,
200200 / .D S _ S t o r e /
201201 ]
202- } )
202+ } ) ,
203+ new webpack . DefinePlugin ( {
204+ 'process.env' : {
205+ 'ADD_SW' : config [ 'service-worker' ]
206+ }
207+ } ) ,
203208] ) ;
204209
205210const htmlPlugin = ( config , src ) => {
You can’t perform that action at this time.
0 commit comments