-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
6,186 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
[![Gitter](https://img.shields.io/gitter/room/nkbt/help.svg?style=flat-square)](https://gitter.im/nkbt/help) | ||
|
||
[![CircleCI](https://img.shields.io/circleci/project/nkbt/react-debounce-input.svg?style=flat-square&label=nix-build)](https://circleci.com/gh/nkbt/react-debounce-input) | ||
[![AppVeyor](https://img.shields.io/appveyor/ci/nkbt/react-debounce-input.svg?style=flat-square&label=win-build)](https://ci.appveyor.com/project/nkbt/react-debounce-input) | ||
[![Coverage](https://img.shields.io/codecov/c/github/nkbt/react-debounce-input.svg?style=flat-square)](https://codecov.io/github/nkbt/react-debounce-input?branch=master) | ||
[![Dependencies](https://img.shields.io/david/nkbt/react-debounce-input.svg?style=flat-square)](https://david-dm.org/nkbt/react-debounce-input) | ||
[![Dev Dependencies](https://img.shields.io/david/dev/nkbt/react-debounce-input.svg?style=flat-square)](https://david-dm.org/nkbt/react-debounce-input#info=devDependencies) | ||
|
@@ -164,13 +163,13 @@ Will result in | |
|
||
Currently is being developed and tested with the latest stable `Node 6` on `OSX` and `Windows`. | ||
|
||
To run example covering all `DebounceInput` features, use `npm start dev`, which will compile `src/example/Example.js` | ||
To run example covering all `DebounceInput` features, use `yarn start dev`, which will compile `src/example/Example.js` | ||
|
||
```bash | ||
git clone [email protected]:nkbt/react-debounce-input.git | ||
cd react-debounce-input | ||
npm install | ||
npm start dev | ||
yarn install | ||
yarn start dev | ||
|
||
# then | ||
open http://localhost:8080 | ||
|
@@ -180,13 +179,13 @@ open http://localhost:8080 | |
|
||
```bash | ||
# to run tests | ||
npm start test | ||
yarn start test | ||
|
||
# to generate test coverage (./reports/coverage) | ||
npm start test.cov | ||
yarn start test.cov | ||
|
||
# to run end-to-end tests | ||
npm start test.e2e | ||
yarn start test.e2e | ||
``` | ||
|
||
## License | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,130 @@ | ||
'use strict'; | ||
|
||
module.exports = require('react-component-template/webpack.config'); | ||
|
||
const webpack = require('webpack'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const path = require('path'); | ||
const pathTo = path.join.bind(null, process.cwd()); | ||
|
||
const {config: {component: COMPONENT_NAME} = {}} = require(pathTo('./package.json')); | ||
|
||
if (!COMPONENT_NAME) { | ||
throw Error('<package.json>.config.component name is required'); | ||
} | ||
|
||
|
||
const loaders = [ | ||
{ | ||
test: /\.css$/, | ||
loader: 'style-loader!css-loader?sourceMap&modules&localIdentName=[path][name]---[local]', | ||
include: [pathTo('src', 'example')] | ||
}, | ||
{ | ||
test: /\.js$/, | ||
loader: 'babel-loader', | ||
include: [pathTo('src')] | ||
} | ||
]; | ||
|
||
|
||
const definePlugin = new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), | ||
'process.env.npm_package_name': JSON.stringify(process.env.npm_package_name) | ||
}); | ||
|
||
|
||
const resolve = {}; | ||
const stats = {colors: true}; | ||
|
||
|
||
const development = { | ||
devtool: '#source-map', | ||
|
||
entry: [ | ||
pathTo('src', 'example', 'Example.js'), | ||
'webpack-dev-server/client?http://localhost:8080' | ||
], | ||
output: {filename: 'bundle.js', path: pathTo('example')}, | ||
plugins: [ | ||
new HtmlWebpackPlugin(), | ||
definePlugin | ||
], | ||
module: { | ||
loaders | ||
}, | ||
resolve, | ||
stats, | ||
devServer: { | ||
historyApiFallback: true, | ||
stats: { | ||
// Do not show list of hundreds of files included in a bundle | ||
chunkModules: false, | ||
colors: true | ||
} | ||
} | ||
}; | ||
|
||
|
||
const ghPages = { | ||
devtool: '#source-map', | ||
entry: pathTo('src', 'example', 'Example.js'), | ||
output: {filename: 'bundle.js', path: pathTo('example')}, | ||
plugins: [new HtmlWebpackPlugin(), definePlugin], | ||
module: {loaders}, | ||
resolve, | ||
stats | ||
}; | ||
|
||
|
||
const dist = { | ||
devtool: '#source-map', | ||
entry: pathTo('src', 'index.js'), | ||
output: { | ||
filename: `${require(pathTo('package.json')).name}.js`, | ||
path: pathTo('build'), | ||
library: COMPONENT_NAME, | ||
libraryTarget: 'umd' | ||
}, | ||
plugins: [definePlugin], | ||
module: {loaders}, | ||
resolve, | ||
stats, | ||
externals: { | ||
react: {root: 'React', commonjs2: 'react', commonjs: 'react', amd: 'react'} | ||
} | ||
}; | ||
|
||
|
||
const min = { | ||
devtool: '#source-map', | ||
entry: pathTo('src', 'index.js'), | ||
output: { | ||
filename: `${require(pathTo('package.json')).name}.min.js`, | ||
path: pathTo('build'), | ||
library: COMPONENT_NAME, | ||
libraryTarget: 'umd' | ||
}, | ||
plugins: [ | ||
definePlugin, | ||
new webpack.optimize.UglifyJsPlugin() | ||
], | ||
module: {loaders}, | ||
resolve, | ||
stats, | ||
externals: { | ||
react: {root: 'React', commonjs2: 'react', commonjs: 'react', amd: 'react'} | ||
} | ||
}; | ||
|
||
|
||
const test = { | ||
output: {libraryTarget: 'commonjs2'}, | ||
module: {loaders} | ||
}; | ||
|
||
|
||
const configs = {development, ghPages, dist, min, test}; | ||
const build = process.env.BUILD || process.env.NODE_ENV || 'development'; | ||
|
||
|
||
module.exports = configs[build]; |
Oops, something went wrong.