How to use the @microsoft/web-library-build.webpack.buildConfig function in @microsoft/web-library-build

To help you get started, we’ve selected a few @microsoft/web-library-build examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / rushstack / core-build / gulp-core-build-webpack / src / webpack.config.ts View on Github external
// Note: this require may need to be fixed to point to the build that exports the gulp-core-build-webpack instance.
const webpackTask: WebpackTask = require('@microsoft/web-library-build').webpack;
const webpack: typeof Webpack = webpackTask.resources.webpack;

const isProduction: boolean = webpackTask.buildConfig.production;

// eslint-disable-next-line
const packageJSON: { name: string } = require('./package.json');

const webpackConfiguration: Webpack.Configuration = {
  context: __dirname,
  devtool: (isProduction) ? undefined : 'source-map',

  entry: {
    [packageJSON.name]: path.join(__dirname, webpackTask.buildConfig.libFolder, 'index.js')
  },

  output: {
    libraryTarget: 'umd',
    path: path.join(__dirname, webpackTask.buildConfig.distFolder),
    filename: `[name]${isProduction ? '.min' : ''}.js`
  },

  // The typings are missing the "object" option here (https://webpack.js.org/configuration/externals/#object)
  externals: {
    'react': {
      amd: 'react',
      commonjs: 'react'
    },
    'react-dom': {
      amd: 'react-dom',
github microsoft / rushstack / core-build / gulp-core-build-webpack / src / webpack.config.ts View on Github external
import * as Webpack from 'webpack';
// @ts-ignore
import * as WebpackDevServer from 'webpack-dev-server'; // eslint-disable-line
import { WebpackTask } from './WebpackTask';
import * as path from 'path';

// Note: this require may need to be fixed to point to the build that exports the gulp-core-build-webpack instance.
const webpackTask: WebpackTask = require('@microsoft/web-library-build').webpack;
const webpack: typeof Webpack = webpackTask.resources.webpack;

const isProduction: boolean = webpackTask.buildConfig.production;

// eslint-disable-next-line
const packageJSON: { name: string } = require('./package.json');

const webpackConfiguration: Webpack.Configuration = {
  context: __dirname,
  devtool: (isProduction) ? undefined : 'source-map',

  entry: {
    [packageJSON.name]: path.join(__dirname, webpackTask.buildConfig.libFolder, 'index.js')
  },

  output: {
    libraryTarget: 'umd',
    path: path.join(__dirname, webpackTask.buildConfig.distFolder),
    filename: `[name]${isProduction ? '.min' : ''}.js`