diff --git a/.gitignore b/.gitignore index 8aea04b2..4958559e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules/ *.swp .lock-wscript lib/ +lib-headless/ out/ out-test/ .nyc_output/ diff --git a/node-test/README.md b/node-test/README.md index b7a67aeb..0da50146 100644 --- a/node-test/README.md +++ b/node-test/README.md @@ -2,8 +2,8 @@ Cursory test that 'xterm-core' works: ``` # From root of this repo -npm run compile # Outputs to xterm-core -npx webpack --config webpack.config.core.js # Outputs to lib +npm run compile # Outputs to out/headless +npx webpack --config webpack.config.headless.js # Outputs to lib cd node-test npm link ../lib/ node index.js diff --git a/src/headless/tsconfig.json b/src/headless/tsconfig.json index 39f71bda..6085a07f 100644 --- a/src/headless/tsconfig.json +++ b/src/headless/tsconfig.json @@ -5,7 +5,7 @@ "es2015", "es2016.Array.Include" ], - "outDir": "../../out/headless", // Temporary outdir to avoid collisions with 'xterm' + "outDir": "../../out", "types": [ "../../node_modules/@types/mocha", "../../node_modules/@types/node" diff --git a/webpack.config.headless.js b/webpack.config.headless.js new file mode 100644 index 00000000..2010e190 --- /dev/null +++ b/webpack.config.headless.js @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const path = require('path'); + +/** + * This webpack config does a production build for xterm.js. It works by taking the output from tsc + * (via `yarn watch` or `yarn prebuild`) which are put into `out/` and webpacks them into a + * production mode umd library module in `lib/`. The aliases are used fix up the absolute paths + * output by tsc (because of `baseUrl` and `paths` in `tsconfig.json`. + */ +module.exports = { + entry: './out/headless/public/Terminal.js', + devtool: 'source-map', + module: { + rules: [ + { + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre", + exclude: /node_modules/ + } + ] + }, + resolve: { + modules: ['./node_modules'], + extensions: [ '.js' ], + alias: { + common: path.resolve('./out/common'), + headless: path.resolve('./out/headless') + } + }, + output: { + filename: 'xterm.js', + path: path.resolve('./lib-headless'), + libraryTarget: 'umd' + }, + mode: 'production' +};