Skip to content

Commit

Permalink
Add webpack build system for global lib build
Browse files Browse the repository at this point in the history
  • Loading branch information
cannoneyed committed Feb 21, 2019
1 parent 42f764c commit f83407b
Show file tree
Hide file tree
Showing 8 changed files with 2,699 additions and 28 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
1,308 changes: 1,308 additions & 0 deletions lib/umap-js.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/umap-js.min.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"types": "dist/index.d.ts",
"scripts": {
"test": "jest",
"build": "rm -rf dist && tsc"
"bundle": "rm -rf lib && webpack --config ./webpack/lib.config.ts && webpack --config ./webpack/lib.min.config.ts",
"build": "rm -rf dist && tsc && yarn bundle"
},
"devDependencies": {
"@types/jest": "^24.0.3",
Expand All @@ -21,8 +22,11 @@
"prando": "^5.1.0",
"prettier": "^1.16.4",
"ts-jest": "^23.10.5",
"ts-loader": "^5.3.3",
"ts-node": "^8.0.2",
"typescript": "^3.2.4"
"typescript": "^3.2.4",
"webpack": "^4.29.5",
"webpack-cli": "^3.2.3"
},
"dependencies": {},
"publishConfig": {
Expand Down
14 changes: 14 additions & 0 deletions src/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Copyright 2019 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

import { UMAP } from './umap';
(window as any).UMAP = UMAP;
25 changes: 25 additions & 0 deletions webpack/lib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as path from 'path';

export default {
mode: 'production',
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: 'ts-loader',
},
],
},
resolve: {
extensions: ['.ts'],
},
entry: {
lib: './src/lib.ts',
},
output: {
filename: 'umap-js.js',
path: path.resolve(__dirname, '../lib'),
},
optimization: { minimize: false },
};
10 changes: 10 additions & 0 deletions webpack/lib.min.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import libConfig from './lib.config';

export default {
...libConfig,
output: {
...libConfig.output,
filename: 'umap-js.min.js',
},
optimization: { minimize: true },
};
Loading

0 comments on commit f83407b

Please sign in to comment.