Permalink
Browse files

Update build environment (#112)

Tweaked the build environment:

* Upgraded to babel6.
* Removed the "loose" parameter in babel, since it's not recommended.
Testing shows no  behaviour difference in the resulting code.
* Added a webpack step to generate a ES5 and <script> friendly module
(webpack is also a devDependency now).
* Added a uglifyjs step to minify the bundle (uglifyjs also a
devDependency now)

react-dropzone can now be hosted on a CDN and used directly in a
<script> tag, although the package attr-accept must also be referenced.
Maybe bake it into the code with webpack?
  • Loading branch information...
1 parent 97372b3 commit 742490d3e1bf2b494bef60936ac43be13726437e @vlindhol vlindhol committed Jan 24, 2016
Showing with 25 additions and 19 deletions.
  1. +2 −2 .babelrc
  2. +1 −0 .gitignore
  3. +1 −1 mocha-environment.js
  4. +10 −3 package.json
  5. +11 −13 webpack.config.js
View
@@ -1,4 +1,4 @@
{
- "stage": 0,
- "loose": "all"
+ "presets": ["es2015", "react", "stage-0"],
+ "plugins": ["add-module-exports"]
}
View
@@ -7,6 +7,7 @@ node_modules
# Generated files
lib
+dist
#IDE
.idea
@@ -1,5 +1,5 @@
// import es6
-require('babel/register');
+require('babel-core/register');
// jsdom
var jsdom = require('jsdom');
View
@@ -4,7 +4,7 @@
"description": "Simple HTML5 drag-drop zone with React.js",
"main": "lib/index.js",
"scripts": {
- "build": "babel ./src --out-dir ./lib",
+ "build": "babel ./src --out-dir ./lib && webpack && uglifyjs ./dist/react-dropzone.js --compress --mangle --output ./dist/react-dropzone.min.js",
"prepublish": "npm run lint && npm test && npm run build",
"test": "mocha --require ./mocha-environment.js './src/test.js'",
"lint": "eslint ./src",
@@ -42,8 +42,13 @@
"attr-accept": "^1.0.3"
},
"devDependencies": {
- "babel": "^5.8.29",
+ "babel-cli": "^6.4.5",
+ "babel-core": "^6.4.5",
"babel-eslint": "^4.1.6",
+ "babel-plugin-add-module-exports": "^0.1.2",
+ "babel-preset-es2015": "^6.3.13",
+ "babel-preset-react": "^6.3.13",
+ "babel-preset-stage-0": "^6.3.13",
"chai": "^3.4.1",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^2.1.1",
@@ -55,6 +60,8 @@
"react-addons-test-utils": "^0.14.3",
"react-dom": "^0.14.3",
"react-testutils-additions": "^0.2.0",
- "sinon": "^1.17.2"
+ "sinon": "^1.17.2",
+ "uglifyjs": "^2.4.10",
+ "webpack": "^1.12.11"
}
}
View
@@ -1,14 +1,12 @@
-{
- module.exports = {
- entry: "./lib/index.js",
- output: {
- path: __dirname,
- filename: "./dist/react-dropzone.js",
- libraryTarget: "var",
- library: "Dropzone"
- },
- externals: {
- "react": "React"
- }
- }
+module.exports = {
+ entry: "./lib/index.js",
+ output: {
+ path: __dirname,
+ filename: "./dist/react-dropzone.js",
+ libraryTarget: "var",
+ library: "Dropzone"
+ },
+ externals: {
+ "react": "React"
+ }
};

0 comments on commit 742490d

Please sign in to comment.