Skip to content

Commit

Permalink
build to multiple module platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
robbymurphy committed Oct 19, 2017
1 parent 1e3da67 commit 779e17d
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 48 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage/*
dist/*
lib/*
es/*
webpack.*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
coverage
dist
node_modules
lib
es
96 changes: 96 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 28 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,39 @@
"name": "redux-jive",
"version": "0.0.1",
"description": "helpers for redux wiring",
"main": "index.js",
"main": "lib/index.js",
"jsnext:main": "es/index.js",
"files": [
"dist",
"lib",
"es",
"src"
],
"scripts": {
"clean": "rimraf dist coverage",
"build:prod": "webpack --config webpack.prod.config.js",
"build:dev": "webpack --config webpack.config.js",
"build": "npm run clean && npm run build:prod && npm run test",
"clean": "rimraf dist coverage lib",
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"build:umd": "cross-env BABEL_ENV=commonjs NODE_ENV=development webpack src/index.js dist/redux-jive.js",
"build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack src/index.js dist/redux-jive.min.js",
"build:all": "npm run build:commonjs && npm run build:umd && npm run build:umd:min && npm run build:es",
"build": "npm run clean && npm run build:all && npm run test",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"test": "jest --coverage",
"test:watch": "npm run build:dev && jest --watchAll"
"test": "jest src --coverage --collectCoverageFrom=**/src/**/*.js --collectCoverageFrom=!src/index.js",
"test:watch": "npm run build:dev && jest src --watchAll"
},
"repository": {
"type": "git",
"url": "git+https://github.com/robbymurphy/redux-jive.git"
},
"keywords": ["redux", "react", "flux"],
"keywords": [
"redux",
"reducer",
"actions",
"middleware",
"async",
"react",
"flux"
],
"author": "Robert Murphy",
"license": "MIT",
"bugs": {
Expand All @@ -27,12 +45,14 @@
"redux": "^3.7.2"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-jest": "^21.2.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"clean-webpack-plugin": "^0.1.17",
"coveralls": "^3.0.0",
"cross-env": "^5.1.0",
"eslint": "^4.9.0",
"eslint-config-airbnb-base": "^12.0.2",
"eslint-loader": "^1.9.0",
Expand Down
55 changes: 30 additions & 25 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
const webpack = require('webpack');
const CleanPlugin = require('clean-webpack-plugin');
const path = require('path');
var webpack = require('webpack');

module.exports = {
entry: {
'redux-jive': path.resolve(__dirname, 'src/index.js'),
vendor: 'redux',
var env = process.env.NODE_ENV;
var config = {
module: {
loaders: [
{ test: /\.js$/, loaders: ['babel-loader', 'eslint-loader'], exclude: /node_modules/ }
]
},
target: 'web',
output: {
path: `${__dirname}/dist`, // Note: Physical files are only output by the production build task `npm run build`.
filename: '[name].js',
library: 'Redux',
libraryTarget: 'umd'
},
plugins: [
new CleanPlugin(['dist']),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
}),
],
module: {
loaders: [
{
test: /\.js$/,
include: path.join(__dirname, 'src'),
loaders: ['babel-loader', 'eslint-loader'],
},
],
},
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(env)
})
]
};

if (env === 'production') {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true,
warnings: false
}
})
);
}

module.exports = config;
15 changes: 0 additions & 15 deletions webpack.prod.config.js

This file was deleted.

0 comments on commit 779e17d

Please sign in to comment.