diff --git a/package.json b/package.json index e0e738b..fbd6b42 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "magnify-3d", - "version": "1.0.0", + "version": "1.0.1", "description": "Real time optic magnifying glass library.", "main": "build/Magnify3d.js", "scripts": { "dev": "./node_modules/.bin/webpack-dev-server --config ./webpack.config.sample --devtool source-map --progress --hot --mode=development", - "build": "NODE_ENV=production webpack --progress --config ./webpack.config.build --mode=production", + "build": "rm -rf ./build && cross-env NODE_ENV=rollup rollup -c", "build-sample": "NODE_ENV=production webpack --progress --config ./webpack.config.sample --mode=production", - "deploy-sample": "gh-pages -d build/sample" + "deploy-sample": "npm run build-sample && gh-pages -d build/sample" }, "author": "Amit Diamant", "repository": { @@ -16,17 +16,28 @@ }, "license": "MIT", "devDependencies": { + "babel-cli": "6.23.0", "babel-core": "^6.26.3", "babel-loader": "^7.1.4", "clean-webpack-plugin": "^1.0.1", "copy-webpack-plugin": "^5.0.0", + "cross-env": "2.0.1", "dat.gui": "^0.7.5", "gh-pages": "^2.0.1", "html-webpack-plugin": "^3.2.0", + "npm-run-all": "4.0.1", + "rollup": "^0.57.1", + "rollup-plugin-babel": "^3.0.3", + "rollup-plugin-commonjs": "^9.1.0", + "rollup-plugin-glsl": "^1.3.0", + "rollup-plugin-node-resolve": "^3.3.0", + "rollup-plugin-replace": "^2.0.0", + "rollup-plugin-uglify": "^3.0.0", "webpack": "4.29.3", "webpack-cli": "^3.2.3", "webpack-dev-server": "^3.1.14", - "webpack-glsl-loader": "1.0.1" + "webpack-glsl-loader": "1.0.1", + "three": "^0.92.0" }, "peerDependencies": { "three": "^0.92.0" diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..02276fd --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,41 @@ +import nodeResolve from 'rollup-plugin-node-resolve'; +import commonjs from 'rollup-plugin-commonjs'; +import babel from 'rollup-plugin-babel'; +import replace from 'rollup-plugin-replace'; +import uglify from 'rollup-plugin-uglify'; +import glsl from 'rollup-plugin-glsl'; + +export default { + input: './src/Magnify3d.js', + output: { + file: 'build/Magnify3d.js', + format: 'umd', + name: 'Magnify3d', + globals: { + three: 'THREE', + }, + }, + external: ['three'], + plugins: [ + nodeResolve(), + commonjs({ + include: 'node_modules/**', + }), + glsl({ + include: 'src/shaders/*.glsl' + }), + babel({ + exclude: 'node_modules/**', + }), + replace({ + 'process.env.NODE_ENV': JSON.stringify('development'), + }), + uglify({ + mangle: false, + output: { + comments: false, + beautify: false, + }, + }), + ], +}; diff --git a/webpack.config.build.js b/webpack.config.build.js deleted file mode 100644 index ca16835..0000000 --- a/webpack.config.build.js +++ /dev/null @@ -1,49 +0,0 @@ -const webpack = require('webpack'); -const CleanWebpackPlugin = require('clean-webpack-plugin'); -const path = require('path'); - -module.exports = { - entry: { - app: './src/Magnify3d.js' - }, - module: { - rules: [ - { - test: /.jsx?$/, - exclude: [/node_modules/], - loader: 'babel-loader' - }, - { - test: /\.glsl$/, - loader: 'webpack-glsl-loader' - } - ] - }, - plugins: [ - new CleanWebpackPlugin(['build']), - ], - optimization: { - minimize: false, - splitChunks: { - cacheGroups: { - commons: { - test: /[\\/]node_modules[\\/]/, - name: 'vendors', - chunks: 'all' - } - } - } - }, - resolve: { - modules: [ - path.resolve('./src'), - path.resolve('./src/shaders'), - 'node_modules' - ], - }, - output: { - filename: 'Magnify3d.js', - chunkFilename: '[name]-[chunkhash].js', - path: path.resolve(__dirname, "./build") - } -};