-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
6,662 additions
and
3,789 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,27 @@ | ||
{ | ||
"presets": [ | ||
"next/babel", | ||
["env", { | ||
"targets": { | ||
"browsers": ["last 2 versions"], | ||
"node": "current" | ||
} | ||
}] | ||
], | ||
"presets": ["next/babel"], | ||
"plugins": [ | ||
"styled-jsx/babel", | ||
"transform-class-properties", | ||
"transform-inline-environment-variables", // inline all process.env.XXX so that they are available in FE as well | ||
[ // https://github.com/zeit/next.js/blob/master/examples/with-global-stylesheet/.babelrc | ||
"wrap-in-js", | ||
{ "extensions": ["css$"] } | ||
], | ||
[ | ||
"transform-assets", | ||
{ | ||
"extensions": ["txt", "svg", "png"], | ||
"regExp": ".*/components/(.+)", | ||
"name": "/static/[1]?[sha512:hash:base64:7]" | ||
} | ||
], | ||
[ | ||
"module-resolver", | ||
{ | ||
"root": ["./"], | ||
"alias": { | ||
"components": "./components", | ||
"constants": "./constants", | ||
"pages": "./pages", | ||
"ducks": "./ducks" | ||
"ducks": "./ducks", | ||
"routes": "./routes" | ||
} | ||
} | ||
] | ||
] | ||
], | ||
|
||
// https://github.com/zeit/next.js/tree/master/examples/with-jest | ||
"env": { | ||
"test": { | ||
"presets": [ | ||
["next/babel", { "preset-env": { "modules": "commonjs" } }] | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** In test environments, next.config.js is not used, thus we need to mock getConfig */ | ||
|
||
function getConfig() { | ||
return { | ||
publicRuntimeConfig: { API_URL: 'API_URL', APP_ID: 'APP_ID' }, | ||
}; | ||
} | ||
|
||
module.exports = getConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,45 @@ | ||
// https://github.com/zeit/next.js/blob/master/examples/with-global-stylesheet/next.config.js | ||
// https://github.com/zeit/next-plugins/tree/master/packages/next-css | ||
// | ||
const { config } = require('./package.json'); | ||
const withCSS = require('@zeit/next-css'); | ||
|
||
module.exports = { | ||
webpack: config => { | ||
config.module.rules.push( | ||
{ | ||
test: /\.css$/, | ||
loader: 'emit-file-loader', | ||
options: { | ||
name: 'dist/[path][name].[ext]', | ||
}, | ||
}, | ||
{ | ||
test: /\.css$/, | ||
use: ['babel-loader', 'raw-loader', 'postcss-loader'], | ||
} | ||
); | ||
return config; | ||
let envConfig = {}; | ||
|
||
switch (process.env.BUILD_TARGET) { | ||
case 'production': | ||
envConfig = { | ||
API_URL: 'https://cofacts-api.g0v.tw', | ||
APP_ID: 'RUMORS_SITE', | ||
GA_TRACKER: 'UA-98468513-1', | ||
}; | ||
break; | ||
|
||
case 'staging': | ||
envConfig = { | ||
API_URL: 'https://cofacts-api.hacktabl.org', | ||
APP_ID: 'RUMORS_SITE', | ||
GA_TRACKER: 'UA-98468513-5', | ||
}; | ||
break; | ||
|
||
case 'local': | ||
// Own API server started using docker-compose in https://github.com/MrOrz/rumors-api | ||
envConfig = { | ||
API_URL: 'http://localhost:5000', | ||
APP_ID: 'DEV', | ||
}; | ||
break; | ||
|
||
default: | ||
envConfig = { | ||
API_URL: 'https://cofacts-api.hacktabl.org', // Default to staging | ||
APP_ID: 'DEV', | ||
}; | ||
} | ||
|
||
module.exports = withCSS({ | ||
publicRuntimeConfig: { | ||
AUTOTRACK_FILENAME: config.autotrackFileName, | ||
...envConfig, | ||
}, | ||
}; | ||
}); |
Oops, something went wrong.