Permalink
Browse files

Attempts at getting the javascript uglified

  • Loading branch information...
geolessel committed Apr 19, 2017
1 parent ae82eaa commit 3f5351586c17513e67277781e31fc566adb5bed2
Showing with 34 additions and 5 deletions.
  1. +11 −0 brunch-config.js
  2. +7 −3 package.json
  3. +15 −1 priv/js/react_phoenix.js
  4. +1 −1 src/react_phoenix.js
@@ -0,0 +1,11 @@
module.exports = {
files: {
javascripts: {
joinTo: 'react_phoenix.js'
}
},
paths: {
watched: ["src"],
public: "priv/js"
}
};
@@ -7,7 +7,9 @@
"test": "test"
},
"scripts": {
"watch": "babel src --out-dir priv/js --watch",
"watch": "brunch watch --stdin",
"deploy": "brunch build --production",
"watch_babel": "babel src --out-dir priv/js --watch",
"release": "node ./node_modules/babel-cli/bin/babel src/react_phoenix.js | node ./node_modules/uglify-js/bin/uglifyjs - --mangle --compress --output priv/js/react_phoenix.js"
},
"repository": {
@@ -21,9 +23,11 @@
},
"homepage": "https://github.com/geolessel/react-phoenix#readme",
"devDependencies": {
"babel-brunch": "~6.0.0",
"babel-cli": "^6.24.1",
"babel-preset-env": "^1.4.0",
"babel-preset-es2016": "^6.24.1",
"uglify-js": "^2.8.22"
"react": "^15.5.4",
"react-dom": "^15.5.4",
"uglify-js-brunch": "^2.8.22"
}
}
@@ -1 +1,15 @@
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,a,r){return a&&e(t.prototype,a),r&&e(t,r),t}}(),_react=require("react"),_react2=_interopRequireDefault(_react),_reactDom=require("react-dom"),_reactDom2=_interopRequireDefault(_reactDom),ReactPhoenix=function(){function ReactPhoenix(){_classCallCheck(this,ReactPhoenix)}return _createClass(ReactPhoenix,[{key:"init",value:function init(){var elements=document.querySelectorAll("[data-react-class]");elements.forEach(function(e){var targetId=document.getElementById(e.dataset.reactTargetId),targetDiv=targetId||e,reactProps=e.dataset.reactProps?e.dataset.reactProps:"{}",reactElement=_react2.default.createElement(eval(e.dataset.reactClass),JSON.parse(reactProps));_reactDom2.default.render(reactElement,targetDiv)})}}]),ReactPhoenix}();exports.default=ReactPhoenix;
import React from "react"
import ReactDOM from "react-dom"
export default class ReactPhoenix {
static init() {
const elements = document.querySelectorAll('[data-react-class]')
elements.forEach(e => {
const targetId = document.getElementById(e.dataset.reactTargetId)
const targetDiv = targetId ? targetId : e
const reactProps = e.dataset.reactProps ? e.dataset.reactProps : "{}"
const reactElement = React.createElement(eval(e.dataset.reactClass), JSON.parse(reactProps))
ReactDOM.render(reactElement, targetDiv)
})
}
}
@@ -2,7 +2,7 @@ import React from "react"
import ReactDOM from "react-dom"
export default class ReactPhoenix {
init() {
static init() {
const elements = document.querySelectorAll('[data-react-class]')
elements.forEach(e => {
const targetId = document.getElementById(e.dataset.reactTargetId)

0 comments on commit 3f53515

Please sign in to comment.