Skip to content

Commit

Permalink
add bundle lib without polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
ZxBing0066 committed Jun 10, 2020
1 parent 7f7a3b1 commit 7b6c3a4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# production
/build
/lib
/lib-without-polyfill

# misc
.DS_Store
Expand Down
20 changes: 20 additions & 0 deletions babel-without-polyfill.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": "> 0.25%, not dead",
"useBuiltIns": false,
"corejs": 3
}
],
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-optional-chaining",
"lodash"
]
}
File renamed without changes.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
"test": "echo \"Error: no test specified\" && exit 0",
"start": "NODE_ENV=development webpack-dev-server",
"build": "rm -rf build/ && NODE_ENV=production webpack",
"build:lib": "rm -rf lib/ && babel src/ -d lib/ -x \".js\",\".ts\" --source-maps --ignore \"src/**/__tests__/**/*\"",
"build:lib": "rm -rf lib/ && babel src/ -d lib/ -x \".js\",\".ts\" --config-file \"./babel.config.json\" --source-maps --ignore \"src/**/__tests__/**/*\"",
"build:lib-without-polyfill": "rm -rf lib-without-polyfill/ && babel src/ -d lib-without-polyfill/ -x \".js\",\".ts\" --config-file \"./babel-without-polyfill.config.json\" --source-maps --ignore \"src/**/__tests__/**/*\"",
"stats": "NODE_ENV=production webpack --profile --json > stats.json",
"analyzer": "ANALYZER=true NODE_ENV=production webpack",
"ci": "node --version && babel --version",
"before-publish": "npm run build && npm run build:lib",
"before-publish": "npm run build && npm run build:lib && npm run build:lib-without-polyfill",
"publish:patch": "npm run before-publish && npm version patch && npm publish",
"publish:minor": "npm run before-publish && npm version minor && npm publish",
"publish:major": "npm run before-publish && npm version major && npm publish",
Expand Down
9 changes: 7 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ const isDevelopment = env === 'development';
const analyzer = process.env.ANALYZER;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

const babelOptions = require('./babel.config.json');

const webpackConfig = {
entry: {
main: './src/index.ts'
rapiop: './src/index.ts'
},
output: {
path: path.resolve(__dirname, 'build'),
Expand All @@ -27,7 +29,10 @@ const webpackConfig = {
rules: [
{
test: /\.(ts|js)$/,
use: 'babel-loader',
use: {
loader: 'babel-loader',
options: babelOptions
},
exclude: /node_modules/
}
]
Expand Down

0 comments on commit 7b6c3a4

Please sign in to comment.