Merge pull request #868 from arv/webpack-tagshow

JS: Use webpack for tagshow
This commit is contained in:
Erik Arvidsson
2016-01-15 17:49:28 -05:00
14 changed files with 59 additions and 25 deletions
-1
View File
@@ -10,7 +10,6 @@
"babel-cli": "^6.3.15",
"babel-core": "^6.3.15",
"babel-eslint": "^4.1.5",
"babel-generator": "^6.4.2",
"babel-loader": "^6.2.1",
"babel-plugin-syntax-async-functions": "^6.3.13",
"babel-plugin-syntax-flow": "^6.3.13",
+4 -7
View File
@@ -1,10 +1,7 @@
SRC="node_modules/babel-regenerator-runtime/runtime.js main.js"
SRC="babel-regenerator-runtime src/main.js"
OUT="tagshow.js"
export NODE_ENV=production
export BABEL_ENV=production
export NODE_ENV=$1
export BABEL_ENV=$1
node_modules/.bin/browserify \
-p bundle-collapser/plugin \
$SRC \
| node_modules/.bin/uglifyjs -c -m > $OUT
node_modules/.bin/webpack --progress $SRC $OUT
+6 -17
View File
@@ -9,7 +9,7 @@
"babel-cli": "^6.3.15",
"babel-core": "^6.3.15",
"babel-eslint": "^4.1.5",
"babel-generator": "^6.4.2",
"babel-loader": "^6.2.1",
"babel-plugin-syntax-async-functions": "^6.3.13",
"babel-plugin-syntax-flow": "^6.3.13",
"babel-plugin-transform-async-to-generator": "^6.3.13",
@@ -20,28 +20,17 @@
"babel-polyfill": "^6.3.14",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babelify": "^7.2.0",
"browserify": "^12.0.1",
"bundle-collapser": "^1.2.1",
"chai": "^3.2.0",
"envify": "^3.4.0",
"eslint": "^1.9.0",
"eslint-plugin-react": "^3.8.0",
"flow-bin": "^0.19.1",
"mocha": "^2.3.0",
"uglify-js": "^2.6.1",
"watchify": "^3.6"
"webpack": "^1.12.11"
},
"scripts": {
"start": "watchify -o tagshow.js -t babelify -v -d node_modules/babel-regenerator-runtime/runtime.js main.js",
"build": "./.npm_build_helper.sh",
"pretest": "rm -f tagshow.js && eslint *.js && flow",
"test": "mocha --ui tdd --reporter dot --compilers js:babel-core/register ./*_test.js"
},
"browserify": {
"transform": [
"babelify",
"envify"
]
"start": "./.npm_build_helper.sh development",
"build": "./.npm_build_helper.sh production",
"pretest": "eslint src/ && flow src/",
"test": "mocha --ui tdd --reporter dot --compilers js:babel-core/register src/*_test.js"
}
}
+49
View File
@@ -0,0 +1,49 @@
'use strict';
const path = require('path');
const webpack = require('webpack');
const devMode = process.env.NODE_ENV !== 'production';
// Replaces all process.env.foo with the value of the enviroment variable.
function replaceEnv() {
const replacements = {};
for (const key in process.env) {
replacements[`process.env.${key}`] = JSON.stringify(process.env[key]);
}
return new webpack.DefinePlugin(replacements);
}
const plugins = [replaceEnv()];
if (!devMode) {
plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}));
}
module.exports = {
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
},
plugins,
resolve: {
alias: {
// Make sure all of these instances are using the same copy.
'react': path.resolve('./node_modules/react')
}
},
devtool: devMode ? '#inline-source-map' : '',
watch: devMode
};