Skip to content

Commit

Permalink
Improve build
Browse files Browse the repository at this point in the history
- Use babel more specific rules
- Fix require of dynamic imags with webpack
- Remove some not used deps
  • Loading branch information
maxcnunes committed Jan 16, 2017
1 parent aef5901 commit e3213f8
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 27 deletions.
17 changes: 15 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
{
"presets": ["es2015", "stage-0", "react"],
"plugins": ["transform-runtime"],
"presets": [
["env", { "targets": { "chrome": 53 }, "useBuiltIns": true }],
"stage-1",
"react"
],
"env": {
"production": {
"presets": ["react-optimize"],
"plugins": [
"transform-function-bind",
"babel-plugin-dev-expression"
]
},
"development": {
"plugins": [
"transform-function-bind"
],
"presets": ["react-hmre"]
}
}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules
dist
app/out
out
releases
installers
npm-debug.log
Expand Down
20 changes: 9 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@
"dependencies": {
"axios": "^0.7.0",
"babel-core": "^6.9.1",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"debug": "^2.2.0",
"sqlectron-core": "^7.5.0"
},
Expand All @@ -86,12 +82,13 @@
"babel-core": "^6.6.5",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-transform-function-bind": "^6.8.0",
"babel-preset-env": "^1.1.8",
"babel-preset-react": "^6.5.0",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.5.0",
"babel-preset-react-optimize": "^1.0.1",
"babel-preset-stage-1": "^6.16.0",
"brace": "^0.7.0",
"breakpoint-sass": "^2.6.1",
"classnames": "^2.2.5",
Expand Down Expand Up @@ -139,8 +136,9 @@
"spawn-auto-restart": "^2.0.1",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.13.1",
"webpack-dev-middleware": "^1.6.1",
"webpack-dev-server": "^1.14.1"
"webpack": "^1.14.0",
"webpack-bundle-analyzer": "^2.2.1",
"webpack-dev-middleware": "^1.9.0",
"webpack-dev-server": "^1.16.2"
}
}
6 changes: 0 additions & 6 deletions src/browser/main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
var path = require('path');

/* eslint global-require:0, no-var: 0, no-extend-native: 0, vars-on-top: 0 */
var devMode = (process.argv || []).indexOf('--dev') !== -1;

// enables ES6+ support
if (devMode) {
require('babel-register');

// load the app dependencies
var PATH_APP_NODE_MODULES = path.join(__dirname, '..', '..', 'app', 'node_modules');
require('module').globalPaths.push(PATH_APP_NODE_MODULES);
}

require('babel-polyfill');
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/require-context.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const requireLogos = require.context('./', false, /server-db-client-.*\.png$/);
6 changes: 3 additions & 3 deletions src/renderer/components/server-list-item.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { PropTypes } from 'react';
import { requireLogos } from './require-context';
import { sqlectron } from '../../browser/remote';


/**
* Load icons for supported database clients
*/
const ICONS = sqlectron.db.CLIENTS.reduce((clients, dbClient) => {
/* eslint no-param-reassign:0, global-require:0 */
clients[dbClient.key] = require(`./server-db-client-${dbClient.key}.png`);
/* eslint no-param-reassign:0 */
clients[dbClient.key] = requireLogos(`./server-db-client-${dbClient.key}.png`);
return clients;
}, {});

Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/server-modal-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Select from 'react-select';
import { sqlectron } from '../../browser/remote';
import ConfirmModal from './confim-modal.jsx';
import Message from './message.jsx';
import { requireLogos } from './require-context';


require('react-select/dist/react-select.css');
Expand All @@ -11,7 +12,7 @@ require('./override-select.css');

const CLIENTS = sqlectron.db.CLIENTS.map(dbClient => ({
value: dbClient.key,
logo: require(`./server-db-client-${dbClient.key}.png`), // eslint-disable-line global-require
logo: requireLogos(`./server-db-client-${dbClient.key}.png`),
label: dbClient.name,
defaultPort: dbClient.defaultPort,
disabledFeatures: dbClient.disabledFeatures,
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/containers/query-browser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Query from '../components/query.jsx';
import Loader from '../components/loader.jsx';
import PromptModal from '../components/prompt-modal.jsx';
import MenuHandler from '../menu-handler';
import { requireLogos } from '../components/require-context';


require('./query-browser.css');
Expand All @@ -49,10 +50,10 @@ const STYLES = {


const CLIENTS = sqlectron.db.CLIENTS.reduce((clients, dbClient) => {
/* eslint no-param-reassign:0, global-require:0 */
/* eslint no-param-reassign:0 */
clients[dbClient.key] = {
title: dbClient.name,
image: require(`../components/server-db-client-${dbClient.key}.png`),
image: requireLogos(`./server-db-client-${dbClient.key}.png`),
};
return clients;
}, {});
Expand Down
4 changes: 3 additions & 1 deletion webpack.prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
// var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
require('babel-polyfill');

module.exports = {
Expand Down Expand Up @@ -36,7 +37,7 @@ module.exports = {
],
},
output: {
path: path.join(__dirname, 'app', 'out', 'static'),
path: path.join(__dirname, 'out', 'static'),
filename: '[name].bundle.js',
},
module: {
Expand Down Expand Up @@ -71,6 +72,7 @@ module.exports = {
noParse: [/html2canvas/],
},
plugins: [
// new BundleAnalyzerPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendorCommon',
filename: 'vendor-common.bundle.js',
Expand Down

0 comments on commit e3213f8

Please sign in to comment.