diff --git a/.babelrc b/.babelrc index f5704c30..d165dd04 100644 --- a/.babelrc +++ b/.babelrc @@ -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"] } } diff --git a/.gitignore b/.gitignore index c55426e8..d09620fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ node_modules dist -app/out +out releases installers npm-debug.log diff --git a/package.json b/package.json index e7e622be..c685c320 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -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", @@ -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" } } diff --git a/src/browser/main.js b/src/browser/main.js index 36cca96b..9387af59 100644 --- a/src/browser/main.js +++ b/src/browser/main.js @@ -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'); diff --git a/src/renderer/components/require-context.js b/src/renderer/components/require-context.js new file mode 100644 index 00000000..58c6eb6e --- /dev/null +++ b/src/renderer/components/require-context.js @@ -0,0 +1 @@ +export const requireLogos = require.context('./', false, /server-db-client-.*\.png$/); diff --git a/src/renderer/components/server-list-item.jsx b/src/renderer/components/server-list-item.jsx index 731c5a2c..10d00297 100644 --- a/src/renderer/components/server-list-item.jsx +++ b/src/renderer/components/server-list-item.jsx @@ -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; }, {}); diff --git a/src/renderer/components/server-modal-form.jsx b/src/renderer/components/server-modal-form.jsx index d49b8b30..e82e8725 100644 --- a/src/renderer/components/server-modal-form.jsx +++ b/src/renderer/components/server-modal-form.jsx @@ -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'); @@ -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, diff --git a/src/renderer/containers/query-browser.jsx b/src/renderer/containers/query-browser.jsx index 4f17cbd3..18c29637 100644 --- a/src/renderer/containers/query-browser.jsx +++ b/src/renderer/containers/query-browser.jsx @@ -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'); @@ -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; }, {}); diff --git a/webpack.prod.config.js b/webpack.prod.config.js index dd3529be..fe22af1c 100644 --- a/webpack.prod.config.js +++ b/webpack.prod.config.js @@ -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 = { @@ -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: { @@ -71,6 +72,7 @@ module.exports = { noParse: [/html2canvas/], }, plugins: [ + // new BundleAnalyzerPlugin(), new webpack.optimize.CommonsChunkPlugin({ name: 'vendorCommon', filename: 'vendor-common.bundle.js',