diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..16c30ec --- /dev/null +++ b/.babelrc @@ -0,0 +1,7 @@ +{ + "presets": [ + ["env", { + "modules": false + }] + ] +} diff --git a/index.js b/licenseBanner.txt similarity index 86% rename from index.js rename to licenseBanner.txt index 04926e3..dd7aa97 100644 --- a/index.js +++ b/licenseBanner.txt @@ -10,7 +10,3 @@ * * http://www.apache.org/licenses/LICENSE-2.0 */ - -import dat from './src/dat/index'; - -export default dat; diff --git a/package.json b/package.json index 3c18871..08f675a 100644 --- a/package.json +++ b/package.json @@ -2,39 +2,16 @@ "name": "dat.gui", "version": "0.6.5", "description": "A lightweight graphical user interface for changing variables in JavaScript.", - "main": "index.js", + "main": "build/dat.gui.js", + "module": "build/dat.gui.module.js", "directories": { "test": "tests" }, - "browserify": { - "transform": [ - [ - "babelify", - { - "presets": [ - "es2015" - ] - } - ], - [ - "stringify", - { - "extensions": [ - ".html" - ] - } - ], - [ - "sassify" - ] - ] - }, "scripts": { - "dev": "webpack --progress --colors --watch --config webpack/webpack.config.js --devtool sourcemap", - "build": "npm run build-js && npm run build-css", - "build-js": "webpack --config ./webpack/webpack.config.js --devtool sourcemap && webpack --config ./webpack/webpack.config.min.js", - "build-css": "node-sass src/dat/gui/style.scss build/dat.gui.css", + "dev": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c -w -m inline\" \"serve --port 8080\"", + "build": "rollup -c && rollup -c rollup.config.min.js", "build-docs": "jsdoc2md -f src/dat/gui/GUI.js src/dat/controllers/Controller.js src/dat/controllers/NumberController.js | replace-between --target API.md --token API", + "lint": "eslint src", "postversion": "git push && git push --tags && npm publish" }, "repository": { @@ -48,28 +25,25 @@ }, "homepage": "https://github.com/dataarts/dat.gui#readme", "devDependencies": { - "babel-core": "^6.14.0", - "babel-loader": "^6.2.5", - "babel-plugin-add-module-exports": "^0.2.1", - "babel-preset-stage-0": "^6.5.0", - "css-loader": "^0.25.0", + "babel-core": "^6.26.0", + "babel-plugin-external-helpers": "^6.22.0", + "babel-preset-env": "^1.6.1", + "concurrently": "^3.5.1", "eslint": "^3.5.0", "eslint-config-airbnb-base": "^7.1.0", "eslint-loader": "^1.5.0", "eslint-plugin-import": "^1.15.0", "extend": "^3.0.0", - "html-loader": "^0.4.4", "jsdoc-to-markdown": "^3.0.2", "node-sass": "^3.10.0", "replace-between": "0.0.8", - "sass-loader": "^4.0.2", - "webpack": "1.14.x" - }, - "dependencies": { - "babel-preset-es2015": "^6.14.0", - "babelify": "^7.3.0", - "sassify": "^4.0.0", - "stringify": "^5.1.0" + "rollup": "^0.54.1", + "rollup-plugin-babel": "^3.0.3", + "rollup-plugin-cleanup": "^2.0.0", + "rollup-plugin-node-resolve": "^3.0.2", + "rollup-plugin-sass": "^0.5.3", + "rollup-plugin-uglify": "^2.0.1", + "serve": "^6.4.8" }, "eslintConfig": { "extends": "airbnb-base", diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..445c07a --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,47 @@ +/** + * dat-gui JavaScript Controller Library + * http://code.google.com/p/dat-gui + * + * Copyright 2011 Data Arts Team, Google Creative Lab + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + */ + +import fs from 'fs'; +import path from 'path'; +import resolve from 'rollup-plugin-node-resolve'; +import cleanup from 'rollup-plugin-cleanup'; +import babel from 'rollup-plugin-babel'; +import sass from 'rollup-plugin-sass'; + +const banner = fs.readFileSync(path.join(__dirname, 'licenseBanner.txt')); + +export default { + input: 'src/dat/index.js', + output: [{ + file: './build/dat.gui.js', + format: 'umd', + name: 'dat', + banner: banner + }, { + file: './build/dat.gui.module.js', + format: 'es', + banner: banner + }], + watch: { + include: 'src/**' + }, + plugins: [ + resolve(), + sass({options: {outputStyle: 'compressed'}}), + babel({ + plugins: ['external-helpers'], + exclude: 'node_modules/**' + }), + cleanup() + ] +}; diff --git a/rollup.config.min.js b/rollup.config.min.js new file mode 100644 index 0000000..2ac71fe --- /dev/null +++ b/rollup.config.min.js @@ -0,0 +1,36 @@ +/** + * dat-gui JavaScript Controller Library + * http://code.google.com/p/dat-gui + * + * Copyright 2011 Data Arts Team, Google Creative Lab + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + */ + +import fs from 'fs'; +import path from 'path'; +import defaultConfig from './rollup.config'; +import uglify from 'rollup-plugin-uglify'; + +const banner = fs.readFileSync(path.join(__dirname, 'licenseBanner.txt')); + +export default Object.assign({}, defaultConfig, { + output: { + file: './build/dat.gui.min.js', + format: 'umd', + name: 'dat', + banner: banner + }, + plugins: [...defaultConfig.plugins, uglify({ + output: { + // Preserve license commenting in minified build. + comments: function(node, comment) { + return comment.type === 'comment2'; + } + } + })] +}); diff --git a/src/dat/gui/saveDialogue.html b/src/dat/gui/saveDialogue.html.js similarity index 84% rename from src/dat/gui/saveDialogue.html rename to src/dat/gui/saveDialogue.html.js index a9dd79a..6a9c3d5 100644 --- a/src/dat/gui/saveDialogue.html +++ b/src/dat/gui/saveDialogue.html.js @@ -1,4 +1,4 @@ -
GUI
's constructor:
@@ -18,4 +18,6 @@