Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
HyunSeob committed Mar 30, 2020
0 parents commit 9b6f86e
Show file tree
Hide file tree
Showing 17 changed files with 10,236 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
types
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 100,
"singleQuote": true,
"trailingComma": "es5"
}
12 changes: 12 additions & 0 deletions example/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"plugins": [
"syntax-dynamic-import",
[
"@babel/plugin-transform-runtime",
{
"regenerator": true
}
]
],
"presets": [["@babel/preset-env"]]
}
15 changes: 15 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 🚀 Welcome to your new awesome project!

This project has been created using **webpack scaffold**, you can now run

```
npm run build
```

or

```
yarn build
```

to bundle your application
27 changes: 27 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "tosspayments-example",
"version": "1.0.0",
"description": "My webpack project",
"main": "index.js",
"author": "Toss Payments",
"license": "MIT",
"private": true,
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@webpack-cli/init": "0.2.2",
"babel-loader": "^8.1.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"html-webpack-plugin": "^4.0.3",
"terser-webpack-plugin": "^2.3.5",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3",
"workbox-webpack-plugin": "^5.1.2"
},
"scripts": {
"dev": "NODE_ENV=development webpack-dev-server",
"build": "NODE_ENV=production webpack"
}
}
13 changes: 13 additions & 0 deletions example/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>

<head>
<title>TossPayments 예제</title>
</head>

<body>
<button onclick="startCommonPayment()">인증 결제 (Common)</button>
<button onclick="startDirectPayment()">비인증 결제 (Direct)</button>
</body>

</html>
35 changes: 35 additions & 0 deletions example/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import TossPayments from '../../dist/tosspayments.esm';

const tossPayments = TossPayments('test_ck_OEP59LybZ8Bdv6A1JxkV6GYo7pRe');

window.startCommonPayment = async () => {
const { result } = await tossPayments.requestPayment({
amount: 1000,
productName: '토스 티셔츠',
userName: '토스',
});

if (result === 'SUCCESS') {
alert('결제에 성공했습니다!');
} else if (result === 'CANCELED') {
alert('결제를 취소하였습니다.');
} else if (result === 'FAIL') {
alert('결제에 실패했습니다.');
}
};

window.startDirectPayment = async () => {
const { result } = await tossPayments.requestDirectPayment({
amount: 1000,
productName: '토스 티셔츠',
userName: '토스',
});

if (result === 'SUCCESS') {
alert('결제에 성공했습니다!');
} else if (result === 'CANCELED') {
alert('결제를 취소하였습니다.');
} else if (result === 'FAIL') {
alert('결제에 실패했습니다.');
}
};
68 changes: 68 additions & 0 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

/*
* SplitChunksPlugin is enabled by default and replaced
* deprecated CommonsChunkPlugin. It automatically identifies modules which
* should be splitted of chunk by heuristics using module duplication count and
* module category (i. e. node_modules). And splits the chunks…
*
* It is safe to remove "splitChunks" from the generated configuration
* and was added as an educational example.
*
* https://webpack.js.org/plugins/split-chunks-plugin/
*
*/

/*
* We've enabled TerserPlugin for you! This minifies your app
* in order to load faster and run less javascript.
*
* https://github.com/webpack-contrib/terser-webpack-plugin
*
*/

const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
mode: process.env.NODE_ENV,
plugins: [new webpack.ProgressPlugin(), new HtmlWebpackPlugin({ template: './src/index.html' })],
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[hash].js',
publicPath: '/',
},
devServer: {
contentBase: path.join(__dirname, 'public'),
port: 3000,
hot: true,
},
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
],
},

optimization: {
minimizer: [new TerserPlugin()],

splitChunks: {
cacheGroups: {
vendors: {
priority: -10,
test: /[\\/]node_modules[\\/]/,
},
},

chunks: 'async',
minChunks: 1,
minSize: 30000,
name: true,
},
},
};
Loading

0 comments on commit 9b6f86e

Please sign in to comment.