The code powering m.abunchtell.com https://m.abunchtell.com
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

91 satır
2.8 KiB

  1. // Note: You must restart bin/webpack-dev-server for changes to take effect
  2. const webpack = require('webpack');
  3. const { basename, dirname, join, relative, resolve, sep } = require('path');
  4. const { sync } = require('glob');
  5. const ExtractTextPlugin = require('extract-text-webpack-plugin');
  6. const ManifestPlugin = require('webpack-manifest-plugin');
  7. const extname = require('path-complete-extname');
  8. const { env, settings, themes, output, loadersDir } = require('./configuration.js');
  9. const localePackPaths = require('./generateLocalePacks');
  10. const extensionGlob = `**/*{${settings.extensions.join(',')}}*`;
  11. const entryPath = join(settings.source_path, settings.source_entry_path);
  12. const packPaths = sync(join(entryPath, extensionGlob));
  13. const entryPacks = [...packPaths, ...localePackPaths].filter(path => path !== join(entryPath, 'custom.js'));
  14. const themePaths = Object.keys(themes).reduce(
  15. (themePaths, name) => {
  16. themePaths[name] = resolve(join(settings.source_path, themes[name]));
  17. return themePaths;
  18. }, {});
  19. module.exports = {
  20. entry: Object.assign(
  21. entryPacks.reduce(
  22. (map, entry) => {
  23. const localMap = map;
  24. let namespace = relative(join(entryPath), dirname(entry));
  25. if (namespace === join('..', '..', '..', 'tmp', 'packs')) {
  26. namespace = ''; // generated by generateLocalePacks.js
  27. }
  28. localMap[join(namespace, basename(entry, extname(entry)))] = resolve(entry);
  29. return localMap;
  30. }, {}
  31. ), themePaths
  32. ),
  33. output: {
  34. filename: '[name].js',
  35. chunkFilename: '[name].js',
  36. path: output.path,
  37. publicPath: output.publicPath,
  38. },
  39. module: {
  40. rules: sync(join(loadersDir, '*.js')).map(loader => require(loader)),
  41. },
  42. plugins: [
  43. new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))),
  44. new ExtractTextPlugin(env.NODE_ENV === 'production' ? '[name]-[hash].css' : '[name].css'),
  45. new ManifestPlugin({
  46. publicPath: output.publicPath,
  47. writeToFileEmit: true,
  48. }),
  49. new webpack.optimize.CommonsChunkPlugin({
  50. name: 'common',
  51. minChunks: (module, count) => {
  52. const reactIntlPathRegexp = new RegExp(`node_modules\\${sep}react-intl`);
  53. if (module.resource && reactIntlPathRegexp.test(module.resource)) {
  54. // skip react-intl because it's useless to put in the common chunk,
  55. // e.g. because "shared" modules between zh-TW and zh-CN will never
  56. // be loaded together
  57. return false;
  58. }
  59. return count >= 2;
  60. },
  61. }),
  62. ],
  63. resolve: {
  64. extensions: settings.extensions,
  65. modules: [
  66. resolve(settings.source_path),
  67. 'node_modules',
  68. ],
  69. },
  70. resolveLoader: {
  71. modules: ['node_modules'],
  72. },
  73. node: {
  74. // Called by http-link-header in an API we never use, increases
  75. // bundle size unnecessarily
  76. Buffer: false,
  77. },
  78. };