File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,28 @@ ember install ember-cli-netlify
2121Usage
2222------------------------------------------------------------------------------
2323
24- Just define a ` .netlifyheaders ` and/or a ` .netlifyredirects ` file in the root of your project and this
24+ ### .netlifyheaders and/or .netlifyredirects
25+
26+ There are a couple ways to use this addon. The first one is to define a ` .netlifyheaders `
27+ and/or a ` .netlifyredirects ` file in the root of your project and this
2528addon will copy the output to ` dist/_headers ` and ` dist/_redirects ` respectively.
2629
30+ ### ember-cli-build.js
31+
32+ The second way is to define an ` ember-cli-netlify ` hash in your ` ember-cli-build.js ` .
33+ You can combine these methods, and anything defined in the config hash will be
34+ appended to the existing files. Currently, only redirects are supported, not headers.
35+
36+ ``` js
37+ ' ember-cli-netlify' : {
38+ redirects: [
39+ ' https://blog.shipshape.io/* https://shipshape.io/blog/:splat 301!' ,
40+ ' https://blog.shipshape.io/* https://shipshape.io/blog/:splat 301!'
41+ ]
42+ }
43+ ```
44+
45+
2746Contributing
2847------------------------------------------------------------------------------
2948
Original file line number Diff line number Diff line change @@ -5,12 +5,24 @@ const fs = require('fs-extra');
55module . exports = {
66 name : require ( './package' ) . name ,
77 outputReady ( ) {
8+ const netlifyOptions = this . app . options [ 'ember-cli-netlify' ] ;
9+
810 if ( fs . pathExistsSync ( '.netlifyheaders' ) ) {
911 fs . copySync ( '.netlifyheaders' , 'dist/_headers' , { clobber : true } ) ;
1012 }
1113
1214 if ( fs . pathExistsSync ( '.netlifyredirects' ) ) {
1315 fs . copySync ( '.netlifyredirects' , 'dist/_redirects' , { clobber : true } ) ;
16+ } else if ( netlifyOptions && netlifyOptions . redirects ) {
17+ fs . writeFileSync ( 'dist/_redirects' ) ;
18+ }
19+
20+ if ( netlifyOptions && netlifyOptions . redirects ) {
21+ const stream = fs . createWriteStream ( 'dist/_redirects' , { flags : 'a' } ) ;
22+ netlifyOptions . redirects . forEach ( ( redirect ) => {
23+ stream . write ( `${ redirect } \n` ) ;
24+ } ) ;
25+ stream . end ( ) ;
1426 }
1527 }
1628} ;
You can’t perform that action at this time.
0 commit comments