Skip to content

Commit

Permalink
next 6; babel config -> next config
Browse files Browse the repository at this point in the history
  • Loading branch information
inian committed May 1, 2018
1 parent 99627da commit 1fe995d
Show file tree
Hide file tree
Showing 7 changed files with 925 additions and 959 deletions.
8 changes: 0 additions & 8 deletions .babelrc

This file was deleted.

6 changes: 4 additions & 2 deletions components/result.js
Expand Up @@ -14,13 +14,15 @@ import { ToastContainer } from "react-toastify";
import { style, toast } from "react-toastify";
import { countryList } from "../data/countryList";
import { deviceList, connectionList } from "../data/devAndConList";
import getConfig from "next/config";

style({
colorDefault: "#153B58",
colorProgressDefault: "#db3340",
width: "500px"
});

const { publicRuntimeConfig } = getConfig();
const humanCount = 1000;
const defaultUrl = "https://google.com";
const devAndconAndconuDefault = "all";
Expand Down Expand Up @@ -215,7 +217,7 @@ class ResultComponent extends React.Component {
if (!input) {
return Promise.resolve({ options: [] });
}
return fetch(`${process.env.BACKEND_URL}/search`, {
return fetch(`${publicRuntimeConfig.backend_url}/search`, {
method: "post",
headers: {
"Content-Type": "application/json"
Expand Down Expand Up @@ -243,7 +245,7 @@ class ResultComponent extends React.Component {
loading: true
});
const origin = url.origin || url;
const response = await fetch(`${process.env.BACKEND_URL}/content`, {
const response = await fetch(`${publicRuntimeConfig.backend_url}/content`, {
method: "post",
headers: {
"Content-Type": "application/json"
Expand Down
31 changes: 18 additions & 13 deletions components/resultGraph.js
Expand Up @@ -6,7 +6,9 @@ import Autosuggest from "react-autosuggest";
import { PulseLoader } from "react-spinners";
import Visual from "../components/visual";
import ResultScore from "./resultScore";
import getConfig from "next/config";

const { publicRuntimeConfig } = getConfig();
const humanCount = 1000;
const defaultUrl = "https://google.com";

Expand Down Expand Up @@ -123,18 +125,21 @@ class ResultGraph extends React.Component {
loading: true
});
const origin = url.origin || url;
const response = await fetch(`${process.env.BACKEND_URL}/content`, {
method: "post",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
origin,
device,
connection,
country
})
});
const response = await fetch(
`${publicRuntimeConfig.backend_url}/content`,
{
method: "post",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
origin,
device,
connection,
country
})
}
);
if (response.ok) {
const responseJSON = await response.json();
this.setState({
Expand Down Expand Up @@ -193,7 +198,7 @@ class ResultGraph extends React.Component {
if (!input) {
return Promise.resolve({ options: [] });
}
return fetch(`${process.env.BACKEND_URL}/search`, {
return fetch(`${publicRuntimeConfig.backend_url}/search`, {
method: "post",
headers: {
"Content-Type": "application/json"
Expand Down
6 changes: 0 additions & 6 deletions env-config.js

This file was deleted.

18 changes: 6 additions & 12 deletions next.config.js
@@ -1,14 +1,8 @@
module.exports = {
webpack: (config) => {
// Perform customizations to config
config.module.rules = config.module.rules.map(rule => {
if(rule.loader === "babel-loader") {
rule.options.cacheDirectory = false;
}
return rule;
});
const prod = process.env.NODE_ENV === "production";

return config;
},
module.exports = {
publicRuntimeConfig: {
backend_url: "https://ruxt-api.dexecure.com",
ga_id: prod ? "UA-55423842-6" : "UA-xxxxxxxx-x"
}
};

3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -13,10 +13,9 @@
"author": "",
"license": "ISC",
"dependencies": {
"babel-plugin-transform-define": "^1.3.0",
"create-react-class": "^15.6.3",
"es6-promise-debounce": "^1.0.1",
"next": "^5.1.0",
"next": "^6.0.0",
"qs": "^6.5.1",
"react": "^16.3.2",
"react-autocomplete": "^1.7.2",
Expand Down

0 comments on commit 1fe995d

Please sign in to comment.