Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Updating node version for scrutinizer. Adding webpack environment dir…
…ectives in default.config. Introducing webpack_host and webpack_port

directive and updating package.json build scripts.
Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
  • Loading branch information
Piyush3079 committed Jul 15, 2018
1 parent 83f46fb commit ec4c356
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .babelrc
@@ -1,3 +1,3 @@
{
"presets": ["env"]
}
}
1 change: 0 additions & 1 deletion .eslintrc.json
Expand Up @@ -5,7 +5,6 @@
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
Expand Down
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Expand Up @@ -25,4 +25,4 @@ build:
command: './vendor/bin/phpcs --standard=PMAStandard ./ --report=checkstyle --report-file=cs-data --ignore=*/vendor/*,*/build/*'
analysis:
file: 'cs-data' # The reporter filename
format: 'php-cs-checkstyle' # The supported format by Scrutinizer
format: 'php-cs-checkstyle' # The supported format by Scrutinizer
14 changes: 11 additions & 3 deletions doc/config.rst
Expand Up @@ -3409,13 +3409,21 @@ Developer

Enable you to set the working environment for loading js files

.. config:option:: $cfg['webpack_host']
:type: string
:default: `'http://localhost'`

Enable you to start webpack development server on specified host for serving js files
when working in the development environment

.. config:option:: $cfg['webpack_port']
:type: integer
:type: number
:default: 3307

Enable you to start webpack development server for serving js files
when woking in the development environment
Enable you to start webpack development server on specified port for serving js files
when working in the development environment

.. config:option:: $cfg['DBG']
Expand Down
5 changes: 3 additions & 2 deletions js/ajax.js
Expand Up @@ -646,9 +646,10 @@ var AJAX = {
*/
var check = name.split('_');
if (check[check.length - 1] === 'new.js') {
var script_src = '';
var script_src;
if (PMA_commonParams.get('environment') === 'development') {
script_src += 'http://localhost:' + PMA_commonParams.get('webpack_port') + '/js/dist/';
script_src = PMA_commonParams.get('webpack_host') + ':'
+ PMA_commonParams.get('webpack_port') + '/js/dist/';
} else if (PMA_commonParams.get('environment') === 'production') {
script_src = 'js/dist/';
}
Expand Down
1 change: 1 addition & 0 deletions libraries/classes/Header.php
Expand Up @@ -236,6 +236,7 @@ public function getJsParams(): array

$params = [
'environment' => $GLOBALS['cfg']['environment'],
'webpack_host' => $GLOBALS['cfg']['webpack_host'],
'webpack_port' => $GLOBALS['cfg']['webpack_port'],
'common_query' => Url::getCommonRaw(),
'opendb_url' => Util::getScriptNameForOption(
Expand Down
5 changes: 2 additions & 3 deletions libraries/classes/Scripts.php
Expand Up @@ -59,10 +59,9 @@ private function _includeFiles(array $files)
* DOM so that both new and old files can be used simultaneously
* It checks whether the file contains new in its name or not
*/
$src = "";
if ($GLOBALS['cfg']['environment'] === 'development') {
$src = "http://localhost:" . $GLOBALS['cfg']['webpack_port'] . "/";
} else if ($GLOBALS['cfg']['environment'] === 'production'){
$src = "";
$src = $GLOBALS['cfg']['webpack_host'] . ":" . $GLOBALS['cfg']['webpack_port'] . "/";
}
$result .= '<script data-cfasync="false" type="text/javascript" src="' . $src . 'js/dist/'
. $value['filename'] . '?' . Header::getVersionParameter() . '"></script>' . "\n";
Expand Down
23 changes: 22 additions & 1 deletion libraries/config.default.php
Expand Up @@ -110,6 +110,23 @@
*/
$cfg['blowfish_secret'] = '';

/**
* Working environment configuration
* for development mode $cfg['environment'] = 'development',
* for making production build $cfg['environment'] = 'production'
*
*/
$cfg['environment'] = 'production';

/**
* Webppack host for running development server of webpack
*/
$cfg['webpack_host'] = 'http://localhost';

/**
* Webppack port number for running development server of webpack
*/
$cfg['webpack_port'] = 3307;

/*******************************************************************************
* Server(s) configuration
Expand Down Expand Up @@ -3014,8 +3031,12 @@

/**
* Additional string to allow in CSP headers.
*
* For working envionment to be development, this has to be changed to allow
* cross-origin loading of js files for specified webpack host and webpack port.
* Eg. 'http://localhost:3307 ws://localhost:3307' for locahost and 3307 webpack pot
*/
$cfg['CSPAllow'] = '';
$cfg['CSPAllow'] = '';

/**
* Disable the table maintenance mass operations, like optimizing or
Expand Down
8 changes: 5 additions & 3 deletions package.json
Expand Up @@ -7,7 +7,9 @@
"license": "GPL-2.0",
"scripts": {
"dev:wds": "webpack-dev-server --progress",
"prod:build": "rimraf lib dist && babel js/es6/ -d lib --ignore .test.js && cross-env NODE_ENV=production webpack -p --progress"
"prod:build": "del js/lib js/dist && babel js/src/ -d js/lib --ignore .test.js && cross-env NODE_ENV=production webpack -p --progress",
"lint:check": "eslint js/src/*.js",
"lint:fix": "eslint js/src/*.js --fix"
},
"dependencies": {
"codemirror": "5.37.0",
Expand All @@ -24,12 +26,12 @@
"zxcvbn": "4.4.2"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-cli": "6.26.0",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"cross-env": "^5.1.5",
"del-cli": "^1.1.0",
"eslint": "^4.9.0",
"rimraf": "^2.6.2",
"webpack": "^4.8.3",
"webpack-cli": "^2.1.3",
"webpack-dev-server": "^3.1.4"
Expand Down
4 changes: 2 additions & 2 deletions webpack.config.babel.js
Expand Up @@ -31,9 +31,9 @@ export default [{
db_search_new: './js/src/db_search.js'
},
output: {
filename: 'js/sql.js',
filename: 'db_search_new.js',
path: path.resolve(__dirname, 'dist'),
publicPath: 'http://localhost:3007/dist'
publicPath: 'http://localhost:3307/js/dist'
},
module: module,
// devtool: 'source-map',
Expand Down

0 comments on commit ec4c356

Please sign in to comment.