You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.7 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. const process = require('process');
  2. const BundleTracker = require('webpack-bundle-tracker');
  3. const VueLoaderPlugin = require('vue-loader/lib/plugin')
  4. const devMode = process.env.DEBUG !== 'False';
  5. const hotReload = process.env.HOT_RELOAD === '1';
  6. const webpackHost = process.env.WEBPACK_HOST || '127.0.0.1';
  7. const webpackPort = process.env.WEBPACK_PORT ? parseInt(process.env.WEBPACK_PORT, 10) : 8080;
  8. const pollMillis = process.env.WEBPACK_POLL_MILLIS ? parseInt(process.env.WEBPACK_POLL_MILLIS, 10) : false;
  9. module.exports = {
  10. mode: devMode ? 'development' : 'production',
  11. entry: {
  12. 'index': './static/js/index.js',
  13. 'sequence_labeling': './static/js/sequence_labeling.js',
  14. 'document_classification': './static/js/document_classification.js',
  15. 'seq2seq': './static/js/seq2seq.js',
  16. 'projects': './static/js/projects.js',
  17. 'stats': './static/js/stats.js',
  18. 'label': './static/js/label.js',
  19. 'guideline': './static/js/guideline.js',
  20. 'demo_text_classification': './static/js/demo/demo_text_classification.js',
  21. 'demo_named_entity': './static/js/demo/demo_named_entity.js',
  22. 'demo_translation': './static/js/demo/demo_translation.js',
  23. 'upload_seq2seq': './static/js/upload_seq2seq.js',
  24. 'upload_sequence_labeling': './static/js/upload_sequence_labeling.js',
  25. 'upload_text_classification': './static/js/upload_text_classification.js',
  26. 'download_seq2seq': './static/js/download_seq2seq.js',
  27. 'download_sequence_labeling': './static/js/download_sequence_labeling.js',
  28. 'download_text_classification': './static/js/download_text_classification.js',
  29. },
  30. output: {
  31. publicPath: hotReload ? `http://127.0.0.1:${webpackPort}/` : '',
  32. path: __dirname + '/static/bundle',
  33. filename: '[name].js'
  34. },
  35. devtool: devMode ? 'cheap-eval-source-map' : 'source-map',
  36. devServer: {
  37. port: webpackPort,
  38. host: webpackHost,
  39. hot: true,
  40. quiet: false,
  41. headers: { 'Access-Control-Allow-Origin': '*' }
  42. },
  43. watchOptions: {
  44. poll: pollMillis,
  45. },
  46. module: {
  47. rules: [
  48. {
  49. test: /\.pug$/,
  50. loader: 'pug-plain-loader'
  51. },
  52. {
  53. test: /\.css$/,
  54. use: [
  55. 'vue-style-loader',
  56. 'css-loader'
  57. ]
  58. },
  59. {
  60. test: /\.vue$/,
  61. loader: 'vue-loader'
  62. }
  63. ]
  64. },
  65. plugins: [
  66. new BundleTracker({ filename: './webpack-stats.json' }),
  67. new VueLoaderPlugin()
  68. ],
  69. resolve: {
  70. extensions: ['.js', '.vue'],
  71. alias: {
  72. vue$: 'vue/dist/vue.esm.js',
  73. },
  74. },
  75. }