Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add browser version to npm distribution #76

Open
RubenVerborgh opened this issue Jan 14, 2019 · 1 comment
Open

Add browser version to npm distribution #76

RubenVerborgh opened this issue Jan 14, 2019 · 1 comment

Comments

@RubenVerborgh
Copy link
Owner

No description provided.

@namedgraph
Copy link
Contributor

namedgraph commented Jul 19, 2019

I have a sample webpack config that does this:

const path = require('path');

const nodeConfig = {
  entry: './src/com/atomgraph/platform/util/URLBuilder.ts',
  mode: 'development',
  devtool: 'inline-source-map',
  module: {
    rules: [
      {
        test: /\.ts?$/,
        use: 'ts-loader',
        exclude: /node_modules/
      }
    ]
  },
  resolve: {
    extensions: [ '.ts', '.js' ]
  },
  target: 'node',
  output: {
    filename: 'URLBuilder.node.js',
    path: path.resolve(__dirname, 'dist')
  }
};

const webConfig = {
  entry: './src/com/atomgraph/platform/util/URLBuilder.ts',
  mode: 'development',
  devtool: 'inline-source-map',
  module: {
    rules: [
      {
        test: /\.ts?$/,
        use: 'ts-loader',
        exclude: /node_modules/
      }
    ]
  },
  resolve: {
    extensions: [ '.ts', '.js' ]
  },
  output: {
    library: ["URLBuilder"],
    libraryTarget: "window",
    filename: 'URLBuilder.js',
    path: path.resolve(__dirname, 'dist')
  }
};

module.exports = [ nodeConfig, webConfig ];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants