webpack.config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. const path = require('path');
  2. module.exports = {
  3. entry: './src/neovis.js',
  4. devtool: "source-map",
  5. output: {
  6. filename: process.env.BUILD_WITH_DEPENDENCIES ? 'neovis.js' : 'neovis-without-dependencies.js',
  7. library: 'NeoVis',
  8. libraryTarget: 'umd',
  9. path: path.resolve(__dirname, 'dist')
  10. },
  11. module: {
  12. rules: [{
  13. test: /\.js$/,
  14. exclude: /node_modules/,
  15. loader: 'babel-loader'
  16. }, {
  17. test: /\.css$/,
  18. use: ['style-loader', 'css-loader']
  19. }, {
  20. test: /\.(png|jpg|gif|svg|eot|ttf|woff2?)$/,
  21. loader: 'url-loader'
  22. }]
  23. },
  24. externals: [
  25. // externalize any library used
  26. (context, request, callback) => {
  27. if(!process.env.BUILD_WITH_DEPENDENCIES && !/^[\\.\/]/.test(request)) {
  28. return callback(null, {
  29. commonjs: request,
  30. commonjs2: request,
  31. amd: request
  32. })
  33. }
  34. callback();
  35. }
  36. ]
  37. };