Skip to content

Commit

Permalink
babel-polyfill fixes, webpack env vars, and fixed https endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
PiggySpeed committed Apr 4, 2018
1 parent fb19d1d commit ebab026
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion daemon/web/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class InertiaClient {
* @param {Object} params
*/
async _post(endpoint, params) {
const request = new Request(endpoint, params);
const request = new Request(this.url + endpoint, params);

try {
return await fetch(request);
Expand Down
2 changes: 1 addition & 1 deletion daemon/web/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class App extends React.Component {
}

async handleLoginSubmit() {
const endpoint = 'https://localhost:8081/web/login';
const endpoint = '/web/login';
const params = {
method: 'POST',
headers: {
Expand Down
1 change: 0 additions & 1 deletion daemon/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

<body>
<div id="app"></div>
<script src="bundle.js"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion daemon/web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import App from './components/App';
import InertiaClient from './client';

// Define where the Inertia daemon is hosted.
const daemonAddress = window.location.host;
const daemonAddress = (process.env.NODE_ENV === 'development') ? '0.0.0.0:8081' : window.location.host;
const client = new InertiaClient(daemonAddress);
ReactDOM.render(<App client={client}/>, document.getElementById('app'));
19 changes: 19 additions & 0 deletions daemon/web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions daemon/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"prop-types": "^15.6.1",
"react": "^16.2.0",
"react-dom": "^16.2.0"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-minify-webpack-plugin": "^0.3.1",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
Expand Down
14 changes: 9 additions & 5 deletions daemon/web/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');

const config = {
mode: 'development',
entry: './index.js',
entry: ['babel-polyfill', './index.js'],
output: {
path: `${__dirname}/public/`,
filename: 'bundle.js',
Expand All @@ -25,24 +25,28 @@ const config = {
{
loader: 'babel-loader',
options: {
presets: ['es2015', 'react', 'stage-3'],
presets: ['es2015', 'stage-3', 'react'],
},
}
],
},
],
},
plugins: [
new webpack.EnvironmentPlugin(['NODE_ENV']),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env': {
// define environment variables here
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
}
}),
new webpack.DefinePlugin({
// suppress react devtools console warning
'__REACT_DEVTOOLS_GLOBAL_HOOK__': '({ isDisabled: true })'
}),
new HtmlWebpackPlugin({
template: './index.html',
filename: 'index.html',
inject: 'body',
inject: 'body'
})
]
};
Expand Down
2 changes: 1 addition & 1 deletion daemon/web/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({

const config = {
mode: 'production',
entry: './index.js',
entry: ['babel-polyfill', './index.js'],
output: {
path: `${__dirname}/public/`,
filename: 'bundle.js',
Expand Down

0 comments on commit ebab026

Please sign in to comment.