diff --git a/Gruntfile.js b/Gruntfile.js index 7c957e2..3e8c862 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,65 +1,76 @@ +var clone = require('clone'); +var webpack = require('webpack'); + module.exports = function (grunt) { // Project configuration. - grunt.initConfig({ + var config = { pkg: grunt.file.readJSON('package.json'), - uglify: { - dist: { - options: { - banner: '/*' + - ' * MIT Licensed' + - ' * http://github.com/flowjs/fusty-flow.js' + - ' * Aidas Klimas' + - ' */', - compress: { - sequences: true, // join consecutive statemets with the “comma operator” - properties: true, // optimize property access: a["foo"] → a.foo - dead_code: true, // discard unreachable code - drop_debugger: true, // discard “debugger” statements - unsafe: false, // some unsafe optimizations (see below) - conditionals: true, // optimize if-s and conditional expressions - comparisons: true, // optimize comparisons - evaluate: true, // evaluate constant expressions - booleans: true, // optimize boolean expressions - loops: true, // optimize loops - unused: true, // drop unused variables/functions - hoist_funs: true, // hoist function declarations - hoist_vars: false, // hoist variable declarations - if_return: true, // optimize if-s followed by return/continue - join_vars: true, // join var declarations - cascade: true, // try to cascade `right` into `left` in sequences - side_effects: true, // drop side-effect-free statements - warnings: true, // warn about potentially dangerous optimizations/code - global_defs: {} // global definitions - } - }, - files: { - 'build/fusty-flow.min.js': [ - 'bower_components/flow.js/src/flow.js', - 'src/fusty-flow-factory.js', - 'src/fusty-flow.js' - ] - } - } - }, - concat: { - flow: { - files: { - 'build/fusty-flow.js': [ - 'bower_components/flow.js/src/flow.js', - 'src/fusty-flow-factory.js', - 'src/fusty-flow.js' - ] - } + webpack: { + standalone: clone(require('./webpack.base.config')), + lib: clone(require('./webpack.base.config')), + libMin: clone(require('./webpack.base.config')) + } + }; + + ////////////////////////////////////// + // Standalone webpack overrides + ////////////////////////////////////// + config.webpack.standalone.output.filename = 'dist/fusty-flow-standalone.js'; + + ////////////////////////////////////// + // Library webpack overrides + ////////////////////////////////////// + config.webpack.lib.output.filename = 'dist/fusty-flow.js'; + + config.webpack.lib.externals = [ + { + 'flow.js': { + 'commonjs': 'flow.js', + 'commonjs2': 'flow.js', + 'amd': 'flow', + 'root': 'Flow' } } - }); + ]; + + ///////////////////////////////////// + //Minified library overrides + ///////////////////////////////////// + config.webpack.libMin.output.filename = 'dist/fusty-flow.min.js'; + + config.webpack.libMin.externals = config.webpack.lib.externals; + + config.webpack.libMin.plugins.push(new webpack.optimize.UglifyJsPlugin({ + compress: { + sequences: true, // join consecutive statemets with the “comma operator” + properties: true, // optimize property access: a["foo"] → a.foo + dead_code: true, // discard unreachable code + drop_debugger: true, // discard “debugger” statements + unsafe: false, // some unsafe optimizations (see below) + conditionals: true, // optimize if-s and conditional expressions + comparisons: true, // optimize comparisons + evaluate: true, // evaluate constant expressions + booleans: true, // optimize boolean expressions + loops: true, // optimize loops + unused: true, // drop unused variables/functions + hoist_funs: true, // hoist function declarations + hoist_vars: false, // hoist variable declarations + if_return: true, // optimize if-s followed by return/continue + join_vars: true, // join var declarations + cascade: true, // try to cascade `right` into `left` in sequences + side_effects: true, // drop side-effect-free statements + warnings: true, // warn about potentially dangerous optimizations/code + global_defs: {} // global definitions + } + })); + + grunt.initConfig(config); - // Load the plugin that provides the "uglify" task. - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-webpack'); // Default task(s). - grunt.registerTask('build', ['uglify', 'concat']); + grunt.registerTask('default', ['build']); + grunt.registerTask('build', ['webpack']); }; \ No newline at end of file diff --git a/bower.json b/bower.json index c6906b4..fce50fd 100644 --- a/bower.json +++ b/bower.json @@ -2,8 +2,7 @@ "name": "fusty-flow.js", "version": "1.2.0", "main": [ - "src/fusty-flow.js", - "src/fusty-flow-factory.js" + "dist/fusty-flow.js" ], "ignore": [ "**/.*", diff --git a/package.json b/package.json index 76195d0..f535222 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "fusty-flow.js", "version": "1.2.0", "description": "Flow.js html5 file upload support for older browsers based on iframe upload.", - "main": "src/fusty-flow-factory.js", + "main": "dist/fusty-flow.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -22,8 +22,14 @@ "license": "MIT", "readmeFilename": "README.md", "devDependencies": { + "babel-polyfill": "^6.3.14", + "clone": "^1.0.2", "grunt": "~0.4.1", - "grunt-contrib-uglify": "~0.11.0", - "grunt-contrib-concat": "~0.5.1" + "grunt-webpack": "^1.0.11", + "webpack": "^1.12.11", + "webpack-dev-server": "^1.14.1" + }, + "dependencies": { + "flow.js": "git@github.com:flowjs/flow.js.git#v2.9.0" } } diff --git a/samples/frontend.html b/samples/frontend.html index 0c38697..1d608c1 100644 --- a/samples/frontend.html +++ b/samples/frontend.html @@ -2,9 +2,8 @@