package-webpack.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. import webpack from 'webpack';
  6. import MonacoWebpackPlugin from '../../webpack-plugin/out/index.js';
  7. import * as path from 'path';
  8. const REPO_ROOT = path.join(__dirname, '../../');
  9. const CROSS_ORIGIN_ASSETS = process.argv.includes('--cross-origin');
  10. webpack(
  11. {
  12. mode: 'development',
  13. entry: './index.js',
  14. context: path.join(__dirname, 'webpack'),
  15. output: {
  16. path: path.resolve(REPO_ROOT, 'test/smoke/webpack/out'),
  17. filename: 'app.js',
  18. publicPath: CROSS_ORIGIN_ASSETS
  19. ? 'http://localhost:8088/monaco-editor/test/smoke/webpack/out/'
  20. : undefined
  21. },
  22. resolve: {
  23. alias: {
  24. 'monaco-editor': path.resolve(REPO_ROOT, 'out/monaco-editor')
  25. }
  26. },
  27. module: {
  28. rules: [
  29. {
  30. test: /\.css$/,
  31. use: ['style-loader', 'css-loader']
  32. },
  33. {
  34. test: /\.ttf$/,
  35. use: ['file-loader']
  36. }
  37. ]
  38. },
  39. plugins: [<any>new MonacoWebpackPlugin({
  40. monacoEditorPath: path.resolve(REPO_ROOT, 'out/monaco-editor')
  41. })]
  42. },
  43. (err: Error | undefined, stats: webpack.Stats | undefined) => {
  44. if (err) {
  45. console.error(err);
  46. process.exit(1);
  47. }
  48. if (stats && stats.hasErrors()) {
  49. console.log(stats.compilation.errors);
  50. process.exit(1);
  51. }
  52. }
  53. );