Skip to content

Commit aa79cf7

Browse files
authored
Merge pull request #67 from back4app/dev-env
Dev env
2 parents 1281671 + 3cf7125 commit aa79cf7

File tree

11 files changed

+86
-14
lines changed

11 files changed

+86
-14
lines changed

Parse-Dashboard/app.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ const path = require('path');
44
const packageJson = require('package-json');
55
const csrf = require('csurf');
66
const Authentication = require('./Authentication.js');
7-
var fs = require('fs');
7+
const fs = require('fs');
8+
const settings = require('@back4app/back4app-settings');
89

910
const currentVersionFeatures = require('../package.json').parseDashboardFeatures;
1011

@@ -201,6 +202,7 @@ module.exports = function(config, options) {
201202
${errors}
202203
<script id="csrf" type="application/json">"${req.csrfToken()}"</script>
203204
<script src="${mountPath}bundles/${loginUrl}"></script>
205+
<script src="${settings.BACK4APP_NAVIGATION_PATH}/back4app-navigation.bundle.js"></script>
204206
</body>
205207
</html>
206208
`);
@@ -224,7 +226,7 @@ module.exports = function(config, options) {
224226
<body>
225227
<div id="browser_mount"></div>
226228
<script src="${mountPath}bundles/${dashboardUrl}"></script>
227-
<script src="https://static.back4app.com/back4app-navigation.bundle.js"></script>
229+
<script src="${settings.BACK4APP_NAVIGATION_PATH}/back4app-navigation.bundle.js"></script>
228230
</body>
229231
</html>
230232
`);

Parse-Dashboard/index.template.html renamed to Parse-Dashboard/index.ejs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<script>
66
PARSE_DASHBOARD_PATH = "/";
77
</script>
8-
<script src="https://static.back4app.com/back4app-navigation.bundle.js"></script>
98
</head>
109
<html>
1110
<title>Parse Dashboard</title>

deploy-homolog.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ branch=$(git symbolic-ref --short HEAD)
1010
git='~/bin/git-parse-dashboard'
1111

1212
ssh -t -i $b4a_certs_path/$pem $user@$host "sudo su back4app -c '. ~/.nvm/nvm.sh && nvm use 9 && cd ~/scm/parse-dashboard && $git reset --hard && $git remote update && $git checkout $branch && $git merge origin/$branch && npm install'"
13-
ssh -t -i $b4a_certs_path/$pem $user@$host "sudo su back4app -c 'cd ~/scm/parse-dashboard && sed -i \"s/http:\/\/localhost:4000\/parseapi/https:\/\/dashboard-homolog.back4app.com\/parseapi/\" node_modules/parse/lib/browser/settings.js && npm run prepublish && npm run build'"
13+
ssh -t -i $b4a_certs_path/$pem $user@$host "sudo su back4app -c '. ~/.nvm/nvm.sh && nvm use 9 && cd ~/scm/parse-dashboard && sed -i \"s/http:\/\/localhost:4000\/parseapi/https:\/\/dashboard-homolog.back4app.com\/parseapi/\" node_modules/parse/lib/browser/settings.js && npm run prepublish && npm run build-homolog'"
1414

1515
#ssh -t aws_B4ANFS_Homolog "sudo su back4app -c '. ~/.nvm/nvm.sh && nvm use 9 && cd ~/scm/back4app-site && yarn install && npm run build && pm2 reload site'"

deploy-prod.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ branch=master
1111
git='~/bin/git-parse-dashboard'
1212

1313
ssh -t -i $b4a_certs_path/$pem $user@$host "sudo su back4app -c 'cp -r ~/scm/parse-dashboard ~/scm/parse-dashboard-$now && . ~/.nvm/nvm.sh && nvm use 9 && cd ~/scm/parse-dashboard && $git reset --hard && $git remote update && $git checkout $branch && $git merge origin/$branch && yarn install --production=false '"
14-
ssh -t -i $b4a_certs_path/$pem $user@$host "sudo su back4app -c 'cd ~/scm/parse-dashboard && sed -i \"s/http:\/\/localhost:4000\/parseapi/https:\/\/dashboard.back4app.com\/parseapi/\" node_modules/parse/lib/browser/settings.js && npm run prepublish && npm run build'"
14+
ssh -t -i $b4a_certs_path/$pem $user@$host "sudo su back4app -c '. ~/.nvm/nvm.sh && nvm use 9 && cd ~/scm/parse-dashboard && sed -i \"s/http:\/\/localhost:4000\/parseapi/https:\/\/dashboard.back4app.com\/parseapi/\" node_modules/parse/lib/browser/settings.js && npm run prepublish && npm run build'"
1515

1616
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/69ace06909c83213745231d2c6d0fd27/purge_cache" -H "X-Auth-Email: $CF_EMAIL" -H "X-Auth-Key: $CF_KEY" -H "Content-Type: application/json" --data '{"files":[
1717
"https://parse-dashboard.back4app.com/bundles/dashboard.bundle.js",

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"LICENSE"
3434
],
3535
"dependencies": {
36+
"@back4app/back4app-settings": "^1.0.1",
3637
"axios": "^0.18.0",
3738
"bcryptjs": "^2.3.0",
3839
"body-parser": "^1.15.2",
@@ -42,6 +43,7 @@
4243
"cookie-session": "^2.0.0-alpha.1",
4344
"csurf": "^1.9.0",
4445
"express": "^4.13.4",
46+
"html-webpack-externals-plugin": "^3.8.0",
4547
"html-webpack-plugin": "^3.2.0",
4648
"jquery": "^3.2.1",
4749
"json-file-plus": "^3.2.0",
@@ -96,10 +98,11 @@
9698
"webpack": "~2.5.1"
9799
},
98100
"scripts": {
99-
"dev": "node ./Parse-Dashboard/index.js & webpack --config webpack/build.config.js --devtool eval-source-map --progress --watch",
101+
"dev": "NODE_ENV=dev webpack --config webpack/build.config.js --devtool eval-source-map --progress --watch",
100102
"dashboard": "node ./Parse-Dashboard/index.js & webpack --config webpack/build.config.js --progress --watch",
101103
"pig": "http-server ./PIG -p 4041 -s & webpack --config webpack/PIG.config.js --progress --watch",
102104
"build": "NODE_ENV=production webpack --config webpack/production.config.js && webpack --config webpack/PIG.config.js",
105+
"build-homolog": "NODE_ENV=homolog webpack --config webpack/homolog.config.js && webpack --config webpack/PIG.config.js",
103106
"test": "NODE_PATH=./node_modules jest",
104107
"lint": "eslint . --ignore-path .gitignore --cache",
105108
"pretest": "npm run lint",

src/dashboard/ServerSettings/ServerSettings.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ export default class ServerSettings extends DashboardView {
3434
let content = (
3535
this.state.appId ?
3636
<div className={styles.content}>
37-
<iframe src={`https://dashboard.back4app.com/apps/settings/${this.state.appId}?showCardsOnly=true`} className={styles.iframeContent}>
37+
<iframe src={`${b4aSettings.DASHBOARD_PATH}/apps/settings/${this.state.appId}?showCardsOnly=true`} className={styles.iframeContent}>
3838
</iframe>
3939
</div> :
40-
<div>Carregando ...</div>
40+
<div>Loading ...</div>
4141
);
4242

4343
return (

webpack/base.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var webpack = require('webpack');
1515
var fs = require('fs');
1616
var json = JSON.parse(fs.readFileSync('package.json', 'utf8'));
1717
var version = json.version;
18+
var settings = require('@back4app/back4app-settings');
1819

1920
module.exports = {
2021
context: path.join(__dirname, '../src'),
@@ -61,9 +62,8 @@ module.exports = {
6162
source: path.join(__dirname,'../src', 'icons')
6263
}),
6364
new webpack.DefinePlugin({
64-
'process.env': {
65-
'version' : JSON.stringify(version)
66-
}
65+
'process.env': { 'version' : JSON.stringify(version) },
66+
b4aSettings: JSON.stringify(settings)
6767
}),
6868
new webpack.ProvidePlugin({
6969
$: 'jquery',

webpack/build.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
var configuration = require('./base.config.js');
99
var HtmlWebpackPlugin = require('html-webpack-plugin');
1010
var path = require('path');
11+
var HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin');
12+
var settings = require('@back4app/back4app-settings');
1113

1214
configuration.entry = {
1315
dashboard: './dashboard/index.js',
@@ -18,8 +20,14 @@ configuration.output.filename = "[name].[chunkhash].js";
1820

1921
configuration.plugins.push(
2022
new HtmlWebpackPlugin({
21-
template: '../Parse-Dashboard/index.template.html',
23+
template: '../Parse-Dashboard/index.ejs',
2224
filename: path.resolve('./Parse-Dashboard/public/index.html')
25+
}),
26+
new HtmlWebpackExternalsPlugin({
27+
externals: [{
28+
module: '@back4app/back4app-navigation',
29+
entry: settings.BACK4APP_NAVIGATION_PATH + '/back4app-navigation.bundle.js'
30+
}]
2331
})
2432
);
2533

webpack/homolog.config.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
var configuration = require('./base.config.js');
2+
var HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin');
3+
var settings = require('@back4app/back4app-settings');
4+
5+
configuration.entry = {
6+
dashboard: './dashboard/index.js',
7+
login: './login/index.js',
8+
PIG: './parse-interface-guide/index.js',
9+
quickstart: './quickstart/index.js',
10+
};
11+
configuration.output.path = require('path').resolve('./production/bundles');
12+
13+
var webpack = require('webpack');
14+
15+
// Enable minification
16+
configuration.plugins.push(
17+
new webpack.DefinePlugin({
18+
'process.env': {
19+
'NODE_ENV': '"homolog"'
20+
}
21+
}),
22+
new webpack.optimize.UglifyJsPlugin({
23+
compress: {
24+
warnings: false
25+
}
26+
}),
27+
new webpack.optimize.OccurrenceOrderPlugin(),
28+
function() {
29+
this.plugin('done', function(stats) {
30+
if (stats.compilation.errors && stats.compilation.errors.length) {
31+
console.log(stats.compilation.errors);
32+
process.exit(1);
33+
}
34+
});
35+
},
36+
new HtmlWebpackExternalsPlugin({
37+
externals: [{
38+
module: '@back4app/back4app-navigation',
39+
entry: settings.BACK4APP_NAVIGATION_PATH + '/back4app-navigation.bundle.js'
40+
}]
41+
})
42+
);
43+
44+
module.exports = configuration;

webpack/production.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* the root directory of this source tree.
77
*/
88
var configuration = require('./base.config.js');
9+
var HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin');
10+
var settings = require('@back4app/back4app-settings');
911

1012
configuration.entry = {
1113
dashboard: './dashboard/index.js',
@@ -37,7 +39,13 @@ configuration.plugins.push(
3739
process.exit(1);
3840
}
3941
});
40-
}
42+
},
43+
new HtmlWebpackExternalsPlugin({
44+
externals: [{
45+
module: '@back4app/back4app-navigation',
46+
entry: settings.BACK4APP_NAVIGATION_PATH + '/back4app-navigation.bundle.js'
47+
}]
48+
})
4149
);
4250

4351
module.exports = configuration;

webpack/publish.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
var configuration = require('./base.config.js');
99
var HtmlWebpackPlugin = require('html-webpack-plugin');
1010
var path = require('path');
11+
var HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin');
12+
var settings = require('@back4app/back4app-settings');
1113

1214
configuration.entry = {
1315
dashboard: './dashboard/index.js',
@@ -32,9 +34,15 @@ configuration.plugins.push(
3234
}),
3335
new webpack.optimize.OccurrenceOrderPlugin(),
3436
new HtmlWebpackPlugin({
35-
template: '../Parse-Dashboard/index.template.html',
37+
template: '../Parse-Dashboard/index.ejs',
3638
filename: path.resolve('./Parse-Dashboard/public/index.html')
3739
}),
40+
new HtmlWebpackExternalsPlugin({
41+
externals: [{
42+
module: '@back4app/back4app-navigation',
43+
entry: settings.BACK4APP_NAVIGATION_PATH + '/back4app-navigation.bundle.js'
44+
}]
45+
}),
3846
function() {
3947
this.plugin('done', function(stats) {
4048
if (stats.compilation.errors && stats.compilation.errors.length) {

0 commit comments

Comments
 (0)