diff --git a/grunt/browser_clients.js b/grunt/browser_clients.js index bd89fb9b9..0bfeed088 100644 --- a/grunt/browser_clients.js +++ b/grunt/browser_clients.js @@ -17,9 +17,9 @@ module.exports = function (grunt) { grunt.task.run([ 'clean:dist', - 'browserify:browser_client', - 'browserify:angular_client', - 'browserify:jquery_client', + 'webpack:browser_client', + 'webpack:angular_client', + 'webpack:jquery_client', 'uglify:dist', 'concat:dist_banners' ]); diff --git a/grunt/config/browserify.js b/grunt/config/browserify.js deleted file mode 100644 index 7d5668a1b..000000000 --- a/grunt/config/browserify.js +++ /dev/null @@ -1,52 +0,0 @@ -module.exports = { - yaml_suite: { - options: { - external: [ - 'optimist' - ], - ignore: [ - 'test/integration/yaml_suite/reporter', - 'src/elasticsearch.js' - ] - }, - files: { - 'test/integration/browser_yaml_suite/yaml_tests.js': 'test/integration/yaml_suite/index.js' - } - }, - browser_client: { - files: { - '<%= distDir %>/elasticsearch.js': 'src/elasticsearch.js' - }, - options: { - standalone: 'elasticsearch', - ignore: [ - 'src/lib/connectors/jquery.js', - 'src/lib/connectors/angular.js' - ] - } - }, - angular_client: { - files: { - '<%= distDir %>/elasticsearch.angular.js': ['src/elasticsearch.angular.js'] - }, - options: { - ignore: [ - 'src/lib/connectors/jquery.js', - 'src/lib/connectors/xhr.js', - 'promise/lib/es6-extensions' - ] - } - }, - jquery_client: { - files: { - '<%= distDir %>/elasticsearch.jquery.js': ['src/elasticsearch.jquery.js'] - }, - options: { - ignore: [ - 'src/lib/connectors/angular.js', - 'src/lib/connectors/xhr.js', - 'promise/lib/es6-extensions' - ] - } - } -}; diff --git a/grunt/config/webpack.js b/grunt/config/webpack.js new file mode 100644 index 000000000..013595d97 --- /dev/null +++ b/grunt/config/webpack.js @@ -0,0 +1,5 @@ +module.exports = { + browser_client: require('../../webpack_config/browser'), + angular_client: require('../../webpack_config/angular'), + jquery_client: require('../../webpack_config/jquery'), +} diff --git a/package.json b/package.json index c204e8974..d612292f8 100644 --- a/package.json +++ b/package.json @@ -41,13 +41,11 @@ ] }, "devDependencies": { - "aliasify": "~1.2.4", "@spalger/eslint-config-personal": "^0.4.0", "async": "~0.8.0", "babel-eslint": "^6.0.4", "blanket": "~1.1.5", "bluebird": "^2.9.14", - "browserify": "~2.35.1", "eslint": "^2.9.0", "eslint-config-airbnb": "^8.0.0", "eslint-plugin-import": "^1.6.1", @@ -58,13 +56,12 @@ "find-root": "~0.1.1", "glob": "~3.2.7", "grunt": "~0.4.1", - "grunt-browserify": "~1.2.11", "grunt-cli": "~0.1.13", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-compress": "~0.5.3", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-copy": "~0.4.1", - "grunt-contrib-uglify": "^0.11.0", + "grunt-contrib-uglify": "^1.0.1", "grunt-contrib-watch": "~0.5.3", "grunt-esvm": "^3.1.1", "grunt-mocha-cov": "^0.4.0", @@ -73,6 +70,7 @@ "grunt-run": "~0.2.2", "grunt-s3": "~0.2.0-alpha.3", "grunt-saucelabs": "~8.2.0", + "grunt-webpack": "^1.0.11", "jquery": "~2.1.1", "js-yaml": "^3.6.0", "load-grunt-config": "~0.7.0", @@ -82,6 +80,7 @@ "mocha-screencast-reporter": "~0.1.4", "moment": "~2.4.0", "nock": "~0.28.3", + "null-loader": "^0.1.1", "open": "0.0.4", "optimist": "~0.6.0", "semver": "^4.3.6", @@ -89,6 +88,8 @@ "split": "~0.3.2", "through2": "~0.6.3", "through2-map": "~1.4.0", + "webpack": "^1.13.0", + "webpack-dev-server": "^1.14.1", "xmlbuilder": "~0.4.3" }, "license": "Apache-2.0", @@ -105,7 +106,8 @@ }, "scripts": { "test": "grunt test", - "generate": "node scripts/generate" + "generate": "node scripts/generate", + "grunt": "grunt" }, "engines": { "node": ">=0.8" diff --git a/webpack_config/angular.js b/webpack_config/angular.js new file mode 100644 index 000000000..c5877d037 --- /dev/null +++ b/webpack_config/angular.js @@ -0,0 +1,25 @@ +const DefinePlugin = require('webpack/lib/DefinePlugin') +const { ignoreLoader, rel } = require('./lib') + +module.exports = { + context: rel('src'), + entry: './elasticsearch.angular.js', + output: { + filename: 'elasticsearch.angular.js', + path: rel('dist'), + }, + module: { + loaders: [ + ignoreLoader([ + 'src/lib/connectors/jquery.js', + 'src/lib/connectors/xhr.js', + 'promise/lib/es6-extensions', + ]), + ], + }, + plugins: [ + new DefinePlugin({ + 'process.env.NODE_ENV': '"production"', + }), + ], +} diff --git a/webpack_config/browser.js b/webpack_config/browser.js new file mode 100644 index 000000000..b96aee110 --- /dev/null +++ b/webpack_config/browser.js @@ -0,0 +1,25 @@ +const DefinePlugin = require('webpack/lib/DefinePlugin') +const { ignoreLoader, rel } = require('./lib') + +module.exports = { + context: rel('src'), + entry: './elasticsearch.js', + output: { + filename: 'elasticsearch.js', + path: rel('dist'), + }, + module: { + loaders: [ + ignoreLoader([ + 'src/lib/connectors/jquery.js', + 'src/lib/connectors/angular.js', + 'promise/lib/es6-extensions', + ]), + ], + }, + plugins: [ + new DefinePlugin({ + 'process.env.NODE_ENV': '"production"', + }), + ], +} diff --git a/webpack_config/jquery.js b/webpack_config/jquery.js new file mode 100644 index 000000000..93c7713fa --- /dev/null +++ b/webpack_config/jquery.js @@ -0,0 +1,25 @@ +const DefinePlugin = require('webpack/lib/DefinePlugin') +const { ignoreLoader, rel } = require('./lib') + +module.exports = { + context: rel('src'), + entry: './elasticsearch.jquery.js', + output: { + filename: 'elasticsearch.jquery.js', + path: rel('dist'), + }, + module: { + loaders: [ + ignoreLoader([ + 'src/lib/connectors/angular.js', + 'src/lib/connectors/xhr.js', + 'promise/lib/es6-extensions', + ]), + ], + }, + plugins: [ + new DefinePlugin({ + 'process.env.NODE_ENV': '"production"', + }), + ], +} diff --git a/webpack_config/lib.js b/webpack_config/lib.js new file mode 100644 index 000000000..b7107e631 --- /dev/null +++ b/webpack_config/lib.js @@ -0,0 +1,21 @@ + +const rel = require('path').resolve.bind(null, __dirname, '..') + +function ignoreLoader(ignores) { + return { + loader: 'null-loader', + test(path) { + return ignores.some(ignore => path.includes(ignore)) + }, + } +} + +function jsLoader() { + return { + loader: 'babel-loader', + test: /\.js$/, + include: rel('src'), + } +} + +module.exports = { ignoreLoader, jsLoader, rel }