Skip to content

Commit

Permalink
chore: UMD distribution support
Browse files Browse the repository at this point in the history
  • Loading branch information
romelperez committed Dec 19, 2020
1 parent 3ead988 commit f463dd6
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/ROADMAP.md
Expand Up @@ -73,7 +73,7 @@ the vision of the project is.
- [ ] [#64](https://github.com/arwes/arwes/issues/64) Arwes UI/UX design specification.
- [ ] [#61](https://github.com/arwes/arwes/issues/61) Migrate project packages
source code to TypeScript.
- [ ] [#62](https://github.com/arwes/arwes/issues/62) Setup UMD distribution support.
- [x] [#62](https://github.com/arwes/arwes/issues/62) Setup UMD distribution support.

#### Playground

Expand Down
2 changes: 1 addition & 1 deletion playground/playground.webpack.config.js
Expand Up @@ -3,7 +3,7 @@ const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const { NODE_ENV } = process.env;
const tsConfigFilePath = path.join(process.cwd(), 'playground/tsconfig.webpack.json');
const tsConfigFilePath = path.join(process.cwd(), 'playground/tsconfig.json');

module.exports = {
mode: NODE_ENV || 'development',
Expand Down
File renamed without changes.
10 changes: 2 additions & 8 deletions scripts/compile-umd.sh
Expand Up @@ -17,21 +17,15 @@ build () {

COMPILE_OUT_PATH=./packages/$1/dist/
COMPILE_SRC=./packages/$1/src/index.ts
COMPILE_OUT_SCOPE=arwes

if [ $1 = "arwes" ]
then
COMPILE_OUT_SCOPE=none
fi

logVerbose "Removing dist path..."
rimraf $COMPILE_OUT_PATH

logVerbose "Compiling development file..."
cross-env NODE_ENV=development COMPILE_SRC=$COMPILE_SRC COMPILE_OUT_PATH=$COMPILE_OUT_PATH COMPILE_OUT_FILENAME=$1.js COMPILE_OUT_SCOPE=$COMPILE_OUT_SCOPE COMPILE_OUT_NAME=$1 webpack --config=./scripts/webpack.compile-umd.config.js
cross-env NODE_ENV=development COMPILE_SRC=$COMPILE_SRC COMPILE_OUT_PATH=$COMPILE_OUT_PATH COMPILE_OUT_FILENAME=$1.js COMPILE_OUT_NAME=$1 webpack --config=./scripts/compile-umd.webpack.config.js

logVerbose "Compiling production file..."
cross-env NODE_ENV=production COMPILE_SRC=$COMPILE_SRC COMPILE_OUT_PATH=$COMPILE_OUT_PATH COMPILE_OUT_FILENAME=$1.min.js COMPILE_OUT_SCOPE=$COMPILE_OUT_SCOPE COMPILE_OUT_NAME=$1 webpack --config=./scripts/webpack.compile-umd.config.js
cross-env NODE_ENV=production COMPILE_SRC=$COMPILE_SRC COMPILE_OUT_PATH=$COMPILE_OUT_PATH COMPILE_OUT_FILENAME=$1.min.js COMPILE_OUT_NAME=$1 webpack --config=./scripts/compile-umd.webpack.config.js
}

logInfo "Compiling Arwes packages for UMD."
Expand Down
Expand Up @@ -6,24 +6,16 @@ const {
COMPILE_SRC,
COMPILE_OUT_PATH,
COMPILE_OUT_FILENAME,
COMPILE_OUT_SCOPE,
COMPILE_OUT_NAME
} = process.env;

// When importing the UMD version of the package "@arwes/arwes", it also imports
// all the other packages. It will be exposed as "[global].arwes".
// Other packages will exposed as "[global].arwes.[packageName]".
const libraryName = COMPILE_OUT_SCOPE !== 'none'
? [COMPILE_OUT_SCOPE, COMPILE_OUT_NAME]
: COMPILE_OUT_NAME;

module.exports = {
mode: NODE_ENV || 'development',
entry: COMPILE_SRC,
output: {
path: path.join(process.cwd(), COMPILE_OUT_PATH),
filename: COMPILE_OUT_FILENAME,
library: libraryName,
library: ['arwes', COMPILE_OUT_NAME],
libraryTarget: 'umd'
},
resolve: {
Expand Down

0 comments on commit f463dd6

Please sign in to comment.