Skip to content

Commit 0b17e8b

Browse files
committed
initial node package config
1 parent 115fdc1 commit 0b17e8b

8 files changed

+5179
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ typings/
5757
# dotenv environment variables file
5858
.env
5959

60+
dist
61+
.DS_Store

example/index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>React Page Turn Example</title>
6+
</head>
7+
<body>
8+
<div id="app"></div>
9+
<script src="http://localhost:8080/webpack-dev-server.js"></script>
10+
<script src="bundle.js"></script>
11+
</body>
12+
</html>

example/index.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
3+
import PageTurn from '../src/index'
4+
5+
const pageStyle = {
6+
7+
};
8+
9+
const pageTitleStyle = {
10+
11+
};
12+
13+
const Page = ({title}) => (
14+
<div style={pageStyle}>
15+
<h1 style={pageTitleStyle}>{title}</h1>
16+
</div>
17+
);
18+
19+
const App = () => (
20+
<PageTurn>
21+
<Page title="Cover" />
22+
<Page title="Cover" />
23+
<Page title="Cover" />
24+
<Page title="Cover" />
25+
</PageTurn>
26+
);
27+
28+
ReactDOM.render(<App />, document.getElementById('app'));

package.json

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"name": "react-page-turn",
3+
"description": "Page turning transition for React components",
4+
"main": "index.js",
5+
"scripts": {
6+
"build": "NODE_ENV=production webpack --config webpack.prod.config.js",
7+
"dev": "webpack-dev-server --progress --colors --hot --content-base ./example --config ./webpack.config.js",
8+
"postbuild": "NODE_ENV=production TARGET=minify webpack --config webpack.prod.config.js",
9+
"prebuild": "rm -rf dist && mkdir dist",
10+
"prepublish": "npm run build",
11+
"test": "echo \"no tests defined\""
12+
},
13+
"version" : "0.0.1",
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/askadev/react-page-turn.git"
17+
},
18+
"bugs": {
19+
"url": "https://github.com/askadev/react-page-turn/issues"
20+
},
21+
"homepage": "https://github.com/drcmda/react-page-turn",
22+
"license": "MIT",
23+
"prettier": {
24+
"semi": true,
25+
"trailingComma": "es5",
26+
"singleQuote": true,
27+
"tabWidth": 2
28+
},
29+
"author": "Tim Shedor <[email protected]> (https://askadev.org)",
30+
"dependencies": {
31+
"react-spring": "^4.1.x"
32+
},
33+
"peerDependencies": {
34+
"react": "0.14.x || ^15.0.0",
35+
"react-dom": "0.14.x || ^15.0.0"
36+
},
37+
"devDependencies": {
38+
"@babel/core": "7.0.0-beta.44",
39+
"@babel/polyfill": "7.0.0-beta.44",
40+
"@babel/preset-env": "7.0.0-beta.44",
41+
"@babel/preset-react": "7.0.0-beta.44",
42+
"@babel/preset-stage-0": "^7.0.0-beta.44",
43+
"babel-loader": "8.0.0-beta.0",
44+
"file-loader": "^1.1.5",
45+
"html-webpack-plugin": "^2.30.1",
46+
"prop-types": "^15.5.10",
47+
"react": "^16.2.0",
48+
"react-dom": "^16.2.0",
49+
"react-hot-loader": "^4.0.0-beta.21",
50+
"webpack": "^3.4.1",
51+
"webpack-dev-server": "^2.6.1"
52+
},
53+
"babel": {
54+
"presets": [
55+
[
56+
"@babel/preset-env",
57+
{
58+
"modules": false
59+
}
60+
],
61+
"@babel/preset-react",
62+
"@babel/preset-stage-0"
63+
],
64+
"plugins": [
65+
"react-hot-loader/babel"
66+
]
67+
}
68+
}

src/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react'
2+
3+
class ReactPageTurn extends React.Component {
4+
5+
render() {
6+
return (
7+
<div>
8+
{this.props.children}
9+
</div>
10+
);
11+
}
12+
};
13+
14+
export default ReactPageTurn;

webpack.config.js

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
const path = require("path")
2+
const webpack = require("webpack")
3+
4+
module.exports = {
5+
devtool: "inline-source-map",
6+
entry: [
7+
"webpack-dev-server/client?http://localhost:8080",
8+
"webpack/hot/only-dev-server",
9+
"./example/index.js"
10+
],
11+
output: {
12+
path: path.join(__dirname, "dist"),
13+
publicPath: "/",
14+
filename: "bundle.js"
15+
},
16+
devServer: {
17+
host: "localhost",
18+
port: 8080,
19+
historyApiFallback: true,
20+
hot: true
21+
},
22+
module: {
23+
rules: [
24+
{
25+
test: /\.jsx?$/,
26+
exclude: /node_modules/,
27+
use: {
28+
loader: "babel-loader",
29+
options: {
30+
presets: [
31+
"@babel/preset-env",
32+
"@babel/preset-react",
33+
"@babel/preset-stage-0"
34+
]
35+
}
36+
}
37+
},
38+
{
39+
test: /\.(jpe?g|png|gif|woff2?|eot|ttf|svg|css)$/,
40+
loader: "file-loader",
41+
options: {
42+
outputPath: "assets/"
43+
}
44+
}
45+
]
46+
},
47+
resolve: {
48+
extensions: [".js", ".jsx"],
49+
modules: [
50+
path.resolve('./node_modules'),
51+
path.resolve('./src')
52+
]
53+
},
54+
plugins: [
55+
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
56+
new webpack.HotModuleReplacementPlugin(),
57+
new webpack.DefinePlugin({
58+
NODE_ENV: JSON.stringify(process.env.NODE_ENV || "development")
59+
}),
60+
new webpack.NoEmitOnErrorsPlugin()
61+
],
62+
node: {
63+
dgram: "empty",
64+
fs: "empty",
65+
net: "empty",
66+
tls: "empty",
67+
child_process: "empty"
68+
}
69+
}

webpack.prod.config.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
var path = require('path');
2+
var webpack = require('webpack');
3+
var TARGET = process.env.TARGET || null;
4+
5+
var externals = {
6+
'react': {
7+
root: 'React',
8+
commonjs2: 'react',
9+
commonjs: 'react',
10+
amd: 'react'
11+
},
12+
'react-spring': {
13+
root: 'ReactSpring',
14+
commonjs2: 'react-spring',
15+
commonjs: 'react-spring',
16+
amd: 'react-spring'
17+
}
18+
};
19+
20+
var config = {
21+
entry: {
22+
index: './src/index.js'
23+
},
24+
output: {
25+
path: path.join(__dirname, 'dist'),
26+
publicPath: 'dist/',
27+
filename: 'react-page-turn.js',
28+
sourceMapFilename: 'react-page-turn.sourcemap.js',
29+
library: 'Transition',
30+
libraryTarget: 'umd'
31+
},
32+
module: {
33+
loaders: [
34+
{ test: /\.(js|jsx)/, loader: 'babel-loader' },
35+
]
36+
},
37+
resolve: {
38+
extensions: ['.js', '.jsx']
39+
},
40+
externals: externals,
41+
plugins: []
42+
};
43+
44+
if (TARGET === 'minify') {
45+
config.output.filename = 'react-page-turn.min.js';
46+
config.output.sourceMapFilename = 'react-page-turn.min.js';
47+
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
48+
compress: {
49+
warnings: false
50+
},
51+
mangle: {
52+
except: ['React', 'ReactMotion', 'Transition', 'getPrefix']
53+
}
54+
}));
55+
}
56+
57+
module.exports = config;

0 commit comments

Comments
 (0)