Skip to content

Commit

Permalink
Using webpack all the way down
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabriskie committed Jun 13, 2015
1 parent ea9a68d commit a1c1028
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 30 deletions.
32 changes: 14 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,23 @@
},
"homepage": "https://github.com/instructure-react/rackt-cli",
"dependencies": {
"browserify": "^6.3.3",
"browserify-shim": "^3.8.0",
"envify": "^3.2.0",
"jsx-loader": "^0.12.2",
"karma": "^0.12.28",
"karma-browserify": "^1.0.0",
"karma-chrome-launcher": "^0.1.6",
"babel-core": "^5.5.6",
"babel-loader": "^5.1.4",
"karma": "^0.12.36",
"karma-browserify": "^4.2.1",
"karma-chrome-launcher": "^0.1.12",
"karma-cli": "0.0.4",
"karma-firefox-launcher": "^0.1.3",
"karma-ie-launcher": "^0.1.5",
"karma-mocha": "^0.1.9",
"karma-firefox-launcher": "^0.1.6",
"karma-ie-launcher": "^0.2.0",
"karma-mocha": "^0.1.10",
"karma-opera-launcher": "^0.1.0",
"karma-phantomjs-launcher": "^0.1.4",
"karma-phantomjs-launcher": "^0.2.0",
"karma-safari-launcher": "^0.1.1",
"minimist": "^1.1.0",
"mocha": "^2.0.1",
"react": "^0.12.1",
"reactify": "^0.17.1",
"minimist": "^1.1.1",
"mocha": "^2.2.5",
"react": "^0.13.3",
"rf-release": "^0.4.0",
"uglify-js": "^2.4.15",
"webpack": "^1.4.13",
"webpack-dev-server": "^1.6.6"
"webpack": "^1.9.10",
"webpack-dev-server": "^1.9.0"
}
}
16 changes: 5 additions & 11 deletions tasks/build
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#!/bin/bash
#!/bin/bash -e

mkdir -p dist

NODE_ENV=production $RACKT_PATH/node_modules/.bin/browserify lib/main.js \
-t reactify \
-t browserify-shim \
-t envify \
--detect-globals false \
-s $COMPONENT_NAME > dist/$COMPONENT_FILE.js
BUILD="$RACKT_PATH/node_modules/.bin/webpack --devtool source-map --config $RACKT_PATH/webpack.build.js"

$RACKT_PATH/node_modules/.bin/uglifyjs dist/$COMPONENT_FILE.js \
--compress warnings=false > dist/$COMPONENT_FILE.min.js
mkdir -p dist
eval $BUILD
eval "MINIFY=1 $BUILD"
26 changes: 26 additions & 0 deletions webpack.build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var path = require('path');
var webpack = require('webpack');
var BASE_DIR = process.cwd();
var COMPONENT_FILE = process.env.COMPONENT_FILE;
var COMPONENT_NAME = process.env.COMPONENT_NAME;
var plugins = [];

if (process.env.MINIFY) {
plugins.push(
new webpack.optimize.UglifyJsPlugin()
);
COMPONENT_FILE += '.min';
}

module.exports = {
entry: path.resolve(BASE_DIR, 'lib/main.js'),
output: {
filename: path.resolve(BASE_DIR, 'dist/' + COMPONENT_FILE + '.js'),
library: COMPONENT_NAME,
libraryTarget: 'umd'
},
externals: {
'react': 'React'
},
plugins: plugins
};
6 changes: 5 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ module.exports = {

module: {
loaders: [
{ test: /\.js$/, loader: 'jsx-loader?harmony' }
{
test: /\.js$/,
exclude: /node_modules/,
loader: path.resolve(process.env.RACKT_PATH, 'node_modules/babel-loader')
}
]
},

Expand Down

0 comments on commit a1c1028

Please sign in to comment.