webpack.config.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. /*eslint-env node*/
  2. /*eslint import/no-nodejs-modules:0 */
  3. const fs = require('fs');
  4. const path = require('path');
  5. const {CleanWebpackPlugin} = require('clean-webpack-plugin'); // installed via npm
  6. const {WebpackManifestPlugin} = require('webpack-manifest-plugin');
  7. const webpack = require('webpack');
  8. const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
  9. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  10. const CompressionPlugin = require('compression-webpack-plugin');
  11. const FixStyleOnlyEntriesPlugin = require('webpack-remove-empty-scripts');
  12. const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
  13. const IntegrationDocsFetchPlugin = require('./build-utils/integration-docs-fetch-plugin');
  14. const OptionalLocaleChunkPlugin = require('./build-utils/optional-locale-chunk-plugin');
  15. const SentryInstrumentation = require('./build-utils/sentry-instrumentation');
  16. const LastBuiltPlugin = require('./build-utils/last-built-plugin');
  17. const babelConfig = require('./babel.config');
  18. const {env} = process;
  19. /**
  20. * Environment configuration
  21. */
  22. const IS_PRODUCTION = env.NODE_ENV === 'production';
  23. const IS_TEST = env.NODE_ENV === 'test' || env.TEST_SUITE;
  24. const IS_STORYBOOK = env.STORYBOOK_BUILD === '1';
  25. // This is used to stop rendering dynamic content for tests/snapshots
  26. // We want it in the case where we are running tests and it is in CI,
  27. // this should not happen in local
  28. const IS_CI = !!env.CI;
  29. // We intentionally build in production mode for acceptance tests, so we explicitly use an env var to
  30. // say that the bundle will be used in acceptance tests. This affects webpack plugins and components
  31. // with dynamic data that render differently statically in tests.
  32. //
  33. // Note, cannot assume it is an acceptance test if `IS_CI` is true, as our image builds has the
  34. // `CI` env var set.
  35. const IS_ACCEPTANCE_TEST = !!env.IS_ACCEPTANCE_TEST;
  36. const IS_DEPLOY_PREVIEW = !!env.NOW_GITHUB_DEPLOYMENT;
  37. const IS_UI_DEV_ONLY = !!env.SENTRY_UI_DEV_ONLY;
  38. const DEV_MODE = !(IS_PRODUCTION || IS_CI);
  39. const WEBPACK_MODE = IS_PRODUCTION ? 'production' : 'development';
  40. /**
  41. * Environment variables that are used by other tooling and should
  42. * not be user configurable.
  43. */
  44. // Ports used by webpack dev server to proxy to backend and webpack
  45. const SENTRY_BACKEND_PORT = env.SENTRY_BACKEND_PORT;
  46. const SENTRY_WEBPACK_PROXY_HOST = env.SENTRY_WEBPACK_PROXY_HOST;
  47. const SENTRY_WEBPACK_PROXY_PORT = env.SENTRY_WEBPACK_PROXY_PORT;
  48. // Used by sentry devserver runner to force using webpack-dev-server
  49. const FORCE_WEBPACK_DEV_SERVER = !!env.FORCE_WEBPACK_DEV_SERVER;
  50. const HAS_WEBPACK_DEV_SERVER_CONFIG = SENTRY_BACKEND_PORT && SENTRY_WEBPACK_PROXY_PORT;
  51. /**
  52. * User/tooling configurable environment variables
  53. */
  54. const NO_DEV_SERVER = !!env.NO_DEV_SERVER; // Do not run webpack dev server
  55. const TS_FORK_WITH_ESLINT = !!env.TS_FORK_WITH_ESLINT; // Do not run eslint with fork-ts plugin
  56. const SHOULD_FORK_TS = DEV_MODE && !env.NO_TS_FORK; // Do not run fork-ts plugin (or if not dev env)
  57. const SHOULD_HOT_MODULE_RELOAD = DEV_MODE && !!env.SENTRY_UI_HOT_RELOAD;
  58. // Deploy previews are built using zeit. We can check if we're in zeit's
  59. // build process by checking the existence of the PULL_REQUEST env var.
  60. const DEPLOY_PREVIEW_CONFIG = IS_DEPLOY_PREVIEW && {
  61. branch: env.NOW_GITHUB_COMMIT_REF,
  62. commitSha: env.NOW_GITHUB_COMMIT_SHA,
  63. githubOrg: env.NOW_GITHUB_COMMIT_ORG,
  64. githubRepo: env.NOW_GITHUB_COMMIT_REPO,
  65. };
  66. // When deploy previews are enabled always enable experimental SPA mode --
  67. // deploy previews are served standalone. Otherwise fallback to the environment
  68. // configuration.
  69. const SENTRY_EXPERIMENTAL_SPA =
  70. !DEPLOY_PREVIEW_CONFIG && !IS_UI_DEV_ONLY ? env.SENTRY_EXPERIMENTAL_SPA : true;
  71. // this is the path to the django "sentry" app, we output the webpack build here to `dist`
  72. // so that `django collectstatic` and so that we can serve the post-webpack bundles
  73. const sentryDjangoAppPath = path.join(__dirname, 'src/sentry/static/sentry');
  74. const distPath = env.SENTRY_STATIC_DIST_PATH || path.join(sentryDjangoAppPath, 'dist');
  75. const staticPrefix = path.join(__dirname, 'static');
  76. /**
  77. * Locale file extraction build step
  78. */
  79. if (env.SENTRY_EXTRACT_TRANSLATIONS === '1') {
  80. babelConfig.plugins.push([
  81. 'module:babel-gettext-extractor',
  82. {
  83. fileName: 'build/javascript.po',
  84. baseDirectory: path.join(__dirname, 'src/sentry'),
  85. functionNames: {
  86. gettext: ['msgid'],
  87. ngettext: ['msgid', 'msgid_plural', 'count'],
  88. gettextComponentTemplate: ['msgid'],
  89. t: ['msgid'],
  90. tn: ['msgid', 'msgid_plural', 'count'],
  91. tct: ['msgid'],
  92. },
  93. },
  94. ]);
  95. }
  96. /**
  97. * Locale compilation and optimizations.
  98. *
  99. * Locales are code-split from the app and vendor chunk into separate chunks
  100. * that will be loaded by layout.html depending on the users configured locale.
  101. *
  102. * Code splitting happens using the splitChunks plugin, configured under the
  103. * `optimization` key of the webpack module. We create chunk (cache) groups for
  104. * each of our supported locales and extract the PO files and moment.js locale
  105. * files into each chunk.
  106. *
  107. * A plugin is used to remove the locale chunks from the app entry's chunk
  108. * dependency list, so that our compiled bundle does not expect that *all*
  109. * locale chunks must be loaded
  110. */
  111. const localeCatalogPath = path.join(
  112. __dirname,
  113. 'src',
  114. 'sentry',
  115. 'locale',
  116. 'catalogs.json'
  117. );
  118. const localeCatalog = JSON.parse(fs.readFileSync(localeCatalogPath, 'utf8'));
  119. // Translates a locale name to a language code.
  120. //
  121. // * po files are kept in a directory represented by the locale name [0]
  122. // * moment.js locales are stored as language code files
  123. // * Sentry will request the user configured language from locale/{language}.js
  124. //
  125. // [0] https://docs.djangoproject.com/en/2.1/topics/i18n/#term-locale-name
  126. const localeToLanguage = locale => locale.toLowerCase().replace('_', '-');
  127. const supportedLocales = localeCatalog.supported_locales;
  128. const supportedLanguages = supportedLocales.map(localeToLanguage);
  129. // A mapping of chunk groups used for locale code splitting
  130. const localeChunkGroups = {};
  131. // No need to split the english locale out as it will be completely empty and
  132. // is not included in the django layout.html.
  133. supportedLocales
  134. .filter(l => l !== 'en')
  135. .forEach(locale => {
  136. const language = localeToLanguage(locale);
  137. const group = `locale/${language}`;
  138. // List of module path tests to group into locale chunks
  139. const localeGroupTests = [
  140. new RegExp(`locale\\/${locale}\\/.*\\.po$`),
  141. new RegExp(`moment\\/locale\\/${language}\\.js$`),
  142. ];
  143. // module test taken from [0] and modified to support testing against
  144. // multiple expressions.
  145. //
  146. // [0] https://github.com/webpack/webpack/blob/7a6a71f1e9349f86833de12a673805621f0fc6f6/lib/optimize/SplitChunksPlugin.js#L309-L320
  147. const groupTest = (module, {chunkGraph}) =>
  148. localeGroupTests.some(pattern =>
  149. module.nameForCondition && pattern.test(module.nameForCondition())
  150. ? true
  151. : chunkGraph.getModuleChunks(module).some(c => c.name && pattern.test(c.name))
  152. );
  153. localeChunkGroups[group] = {
  154. chunks: 'initial',
  155. name: group,
  156. test: groupTest,
  157. enforce: true,
  158. };
  159. });
  160. /**
  161. * Restrict translation files that are pulled in through app/translations.jsx
  162. * and through moment/locale/* to only those which we create bundles for via
  163. * locale/catalogs.json.
  164. */
  165. const localeRestrictionPlugins = [
  166. new webpack.ContextReplacementPlugin(
  167. /sentry-locale$/,
  168. path.join(__dirname, 'src', 'sentry', 'locale', path.sep),
  169. true,
  170. new RegExp(`(${supportedLocales.join('|')})/.*\\.po$`)
  171. ),
  172. new webpack.ContextReplacementPlugin(
  173. /moment\/locale/,
  174. new RegExp(`(${supportedLanguages.join('|')})\\.js$`)
  175. ),
  176. ];
  177. /**
  178. * Explicit codesplitting cache groups
  179. */
  180. const cacheGroups = {
  181. defaultVendors: {
  182. name: 'vendor',
  183. // This `platformicons` check is required otherwise it will get put into this chunk instead
  184. // of `sentry.css` bundle
  185. // TODO(platformicons): Simplify this if we move platformicons into repo
  186. test: module =>
  187. !/platformicons/.test(module.resource) &&
  188. /[\\/]node_modules[\\/]/.test(module.resource),
  189. priority: -10,
  190. enforce: true,
  191. chunks: 'initial',
  192. },
  193. ...localeChunkGroups,
  194. };
  195. const babelOptions = {...babelConfig, cacheDirectory: true};
  196. const babelLoaderConfig = {
  197. loader: 'babel-loader',
  198. options: babelOptions,
  199. };
  200. /**
  201. * Main Webpack config for Sentry React SPA.
  202. */
  203. let appConfig = {
  204. mode: WEBPACK_MODE,
  205. entry: {
  206. /**
  207. * Main Sentry SPA
  208. *
  209. * The order here matters for `getsentry`
  210. */
  211. app: ['app/utils/statics-setup', 'app'],
  212. /**
  213. * Pipeline View for integrations
  214. */
  215. pipeline: ['app/utils/statics-setup', 'app/views/integrationPipeline'],
  216. /**
  217. * Legacy CSS Webpack appConfig for Django-powered views.
  218. * This generates a single "sentry.css" file that imports ALL component styles
  219. * for use on Django-powered pages.
  220. */
  221. sentry: 'less/sentry.less',
  222. /**
  223. * Old plugins that use select2 when creating a new issue e.g. Trello, Teamwork*
  224. */
  225. select2: 'less/select2.less',
  226. },
  227. context: staticPrefix,
  228. module: {
  229. /**
  230. * XXX: Modifying the order/contents of these rules may break `getsentry`
  231. * Please remember to test it.
  232. */
  233. rules: [
  234. {
  235. test: /\.[tj]sx?$/,
  236. include: [staticPrefix],
  237. exclude: /(vendor|node_modules|dist)/,
  238. use: babelLoaderConfig,
  239. },
  240. {
  241. test: /\.po$/,
  242. use: {
  243. loader: 'po-catalog-loader',
  244. options: {
  245. referenceExtensions: ['.js', '.jsx'],
  246. domain: 'sentry',
  247. },
  248. },
  249. },
  250. {
  251. test: /\.css/,
  252. use: ['style-loader', 'css-loader'],
  253. },
  254. {
  255. test: /\.less$/,
  256. include: [staticPrefix],
  257. use: [MiniCssExtractPlugin.loader, 'css-loader', 'less-loader'],
  258. },
  259. {
  260. test: /\.(woff|woff2|ttf|eot|svg|png|gif|ico|jpg|mp4)($|\?)/,
  261. use: [
  262. {
  263. loader: 'file-loader',
  264. options: {
  265. // This needs to be `false` because of platformicons package
  266. esModule: false,
  267. name: '[folder]/[name].[contenthash:6].[ext]',
  268. },
  269. },
  270. ],
  271. },
  272. ],
  273. noParse: [
  274. // don't parse known, pre-built javascript files (improves webpack perf)
  275. /dist\/jquery\.js/,
  276. /jed\/jed\.js/,
  277. /marked\/lib\/marked\.js/,
  278. /terser\/dist\/bundle\.min\.js/,
  279. ],
  280. },
  281. plugins: [
  282. new CleanWebpackPlugin(),
  283. new WebpackManifestPlugin({}),
  284. /**
  285. * jQuery must be provided in the global scope specifically and only for
  286. * bootstrap, as it will not import jQuery itself.
  287. *
  288. * We discourage the use of global jQuery through eslint rules
  289. */
  290. new webpack.ProvidePlugin({
  291. jQuery: 'jquery',
  292. process: 'process/browser',
  293. Buffer: ['buffer', 'Buffer'],
  294. }),
  295. /**
  296. * Extract CSS into separate files.
  297. */
  298. new MiniCssExtractPlugin({
  299. filename: '[name].[contenthash:6].css',
  300. }),
  301. /**
  302. * Defines environment specific flags.
  303. */
  304. new webpack.DefinePlugin({
  305. 'process.env': {
  306. NODE_ENV: JSON.stringify(env.NODE_ENV),
  307. IS_ACCEPTANCE_TEST: JSON.stringify(IS_ACCEPTANCE_TEST),
  308. DEPLOY_PREVIEW_CONFIG: JSON.stringify(DEPLOY_PREVIEW_CONFIG),
  309. EXPERIMENTAL_SPA: JSON.stringify(SENTRY_EXPERIMENTAL_SPA),
  310. SPA_DSN: JSON.stringify(env.SENTRY_SPA_DSN),
  311. },
  312. }),
  313. /**
  314. * See above for locale chunks. These plugins help with that
  315. * functionality.
  316. */
  317. new OptionalLocaleChunkPlugin(),
  318. /**
  319. * This removes empty js files for style only entries (e.g. sentry.less)
  320. */
  321. new FixStyleOnlyEntriesPlugin({verbose: false}),
  322. new SentryInstrumentation(),
  323. ...(SHOULD_FORK_TS
  324. ? [
  325. new ForkTsCheckerWebpackPlugin({
  326. eslint: TS_FORK_WITH_ESLINT,
  327. tsconfig: path.resolve(__dirname, './config/tsconfig.build.json'),
  328. }),
  329. ]
  330. : []),
  331. ...localeRestrictionPlugins,
  332. ],
  333. resolve: {
  334. alias: {
  335. app: path.join(staticPrefix, 'app'),
  336. 'sentry-images': path.join(staticPrefix, 'images'),
  337. 'sentry-logos': path.join(sentryDjangoAppPath, 'images', 'logos'),
  338. 'sentry-fonts': path.join(staticPrefix, 'fonts'),
  339. // Aliasing this for getsentry's build, otherwise `less/select2` will not be able
  340. // to be resolved
  341. less: path.join(staticPrefix, 'less'),
  342. 'sentry-test': path.join(__dirname, 'tests', 'js', 'sentry-test'),
  343. 'sentry-locale': path.join(__dirname, 'src', 'sentry', 'locale'),
  344. 'ios-device-list': path.join(
  345. __dirname,
  346. 'node_modules',
  347. 'ios-device-list',
  348. 'dist',
  349. 'ios-device-list.min.js'
  350. ),
  351. },
  352. fallback: {
  353. vm: false,
  354. stream: false,
  355. crypto: require.resolve('crypto-browserify'),
  356. // `yarn why` says this is only needed in dev deps
  357. string_decoder: false,
  358. },
  359. modules: ['node_modules'],
  360. extensions: ['.jsx', '.js', '.json', '.ts', '.tsx', '.less'],
  361. },
  362. output: {
  363. path: distPath,
  364. publicPath: '',
  365. filename: '[name].[contenthash].js',
  366. chunkFilename: '[name].[contenthash].js',
  367. sourceMapFilename: '[name].js.map',
  368. },
  369. optimization: {
  370. chunkIds: 'named',
  371. moduleIds: 'named',
  372. runtimeChunk: {name: 'runtime'},
  373. splitChunks: {
  374. // Only affect async chunks, otherwise webpack could potentially split our initial chunks
  375. // Which means the app will not load because we'd need these additional chunks to be loaded in our
  376. // django template.
  377. chunks: 'async',
  378. maxInitialRequests: 5,
  379. maxAsyncRequests: 7,
  380. cacheGroups,
  381. },
  382. // This only runs in production mode
  383. // Grabbed this example from https://github.com/webpack-contrib/css-minimizer-webpack-plugin
  384. minimizer: ['...', new CssMinimizerPlugin()],
  385. },
  386. devtool: IS_PRODUCTION ? 'source-map' : 'eval-cheap-module-source-map',
  387. };
  388. if (IS_TEST || IS_ACCEPTANCE_TEST || IS_STORYBOOK) {
  389. appConfig.resolve.alias['integration-docs-platforms'] = path.join(
  390. __dirname,
  391. 'tests/fixtures/integration-docs/_platforms.json'
  392. );
  393. } else {
  394. const plugin = new IntegrationDocsFetchPlugin({basePath: __dirname});
  395. appConfig.plugins.push(plugin);
  396. appConfig.resolve.alias['integration-docs-platforms'] = plugin.modulePath;
  397. }
  398. if (IS_ACCEPTANCE_TEST) {
  399. appConfig.plugins.push(new LastBuiltPlugin({basePath: __dirname}));
  400. }
  401. // Dev only! Hot module reloading
  402. if (
  403. FORCE_WEBPACK_DEV_SERVER ||
  404. (HAS_WEBPACK_DEV_SERVER_CONFIG && !NO_DEV_SERVER) ||
  405. IS_UI_DEV_ONLY
  406. ) {
  407. if (SHOULD_HOT_MODULE_RELOAD) {
  408. // Hot reload react components on save
  409. // We include the library here as to not break docker/google cloud builds
  410. // since we do not install devDeps there.
  411. const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
  412. appConfig.plugins.push(new ReactRefreshWebpackPlugin());
  413. }
  414. appConfig.devServer = {
  415. headers: {
  416. 'Access-Control-Allow-Origin': '*',
  417. 'Access-Control-Allow-Credentials': 'true',
  418. },
  419. // Required for getsentry
  420. disableHostCheck: true,
  421. contentBase: './src/sentry/static/sentry',
  422. host: SENTRY_WEBPACK_PROXY_HOST,
  423. hot: true,
  424. // If below is false, will reload on errors
  425. hotOnly: true,
  426. port: SENTRY_WEBPACK_PROXY_PORT,
  427. stats: 'errors-only',
  428. overlay: false,
  429. watchOptions: {
  430. ignored: ['node_modules'],
  431. },
  432. };
  433. if (!IS_UI_DEV_ONLY) {
  434. // This proxies to local backend server
  435. const backendAddress = `http://localhost:${SENTRY_BACKEND_PORT}/`;
  436. const relayAddress = 'http://127.0.0.1:7899';
  437. appConfig.devServer = {
  438. ...appConfig.devServer,
  439. publicPath: '/_static/dist/sentry',
  440. // syntax for matching is using https://www.npmjs.com/package/micromatch
  441. proxy: {
  442. '/api/store/**': relayAddress,
  443. '/api/{1..9}*({0..9})/**': relayAddress,
  444. '/api/0/relays/outcomes/': relayAddress,
  445. '!/_static/dist/sentry/**': backendAddress,
  446. },
  447. writeToDisk: filePath => {
  448. return /manifest\.json/.test(filePath);
  449. },
  450. };
  451. }
  452. }
  453. // XXX(epurkhiser): Sentry (development) can be run in an experimental
  454. // pure-SPA mode, where ONLY /api* requests are proxied directly to the API
  455. // backend (in this case, sentry.io), otherwise ALL requests are rewritten
  456. // to a development index.html -- thus, completely separating the frontend
  457. // from serving any pages through the backend.
  458. //
  459. // THIS IS EXPERIMENTAL and has limitations (e.g. you can't use SSO)
  460. //
  461. // Various sentry pages still rely on django to serve html views.
  462. if (IS_UI_DEV_ONLY) {
  463. appConfig.devServer = {
  464. ...appConfig.devServer,
  465. compress: true,
  466. https: true,
  467. publicPath: '/_assets/',
  468. proxy: [
  469. {
  470. context: ['/api/', '/avatar/', '/organization-avatar/'],
  471. target: 'https://sentry.io',
  472. secure: false,
  473. changeOrigin: true,
  474. headers: {
  475. Referer: 'https://sentry.io/',
  476. },
  477. },
  478. ],
  479. historyApiFallback: {
  480. rewrites: [{from: /^\/.*$/, to: '/_assets/index.html'}],
  481. },
  482. };
  483. }
  484. if (IS_UI_DEV_ONLY || IS_DEPLOY_PREVIEW) {
  485. appConfig.output.publicPath = '/_assets/';
  486. /**
  487. * Generate a index.html file used for running the app in pure client mode.
  488. * This is currently used for PR deploy previews, where only the frontend
  489. * is deployed.
  490. */
  491. const HtmlWebpackPlugin = require('html-webpack-plugin');
  492. appConfig.plugins.push(
  493. new HtmlWebpackPlugin({
  494. // Local dev vs vercel slightly differs...
  495. ...(IS_UI_DEV_ONLY
  496. ? {devServer: `https://localhost:${SENTRY_WEBPACK_PROXY_PORT}`}
  497. : {}),
  498. favicon: path.resolve(sentryDjangoAppPath, 'images', 'favicon_dev.png'),
  499. template: path.resolve(staticPrefix, 'index.ejs'),
  500. mobile: true,
  501. excludeChunks: ['pipeline'],
  502. title: 'Sentry',
  503. })
  504. );
  505. }
  506. const minificationPlugins = [
  507. // This compression-webpack-plugin generates pre-compressed files
  508. // ending in .gz, to be picked up and served by our internal static media
  509. // server as well as nginx when paired with the gzip_static module.
  510. new CompressionPlugin({
  511. algorithm: 'gzip',
  512. test: /\.(js|map|css|svg|html|txt|ico|eot|ttf)$/,
  513. }),
  514. // NOTE: In production mode webpack will automatically minify javascript
  515. // using the TerserWebpackPlugin.
  516. ];
  517. if (IS_PRODUCTION) {
  518. // NOTE: can't do plugins.push(Array) because webpack/webpack#2217
  519. minificationPlugins.forEach(function (plugin) {
  520. appConfig.plugins.push(plugin);
  521. });
  522. }
  523. // Cache webpack builds
  524. if (env.WEBPACK_CACHE_PATH) {
  525. appConfig.cache = {
  526. type: 'filesystem',
  527. cacheLocation: path.resolve(__dirname, env.WEBPACK_CACHE_PATH),
  528. buildDependencies: {
  529. // This makes all dependencies of this file - build dependencies
  530. config: [__filename],
  531. // By default webpack and loaders are build dependencies
  532. },
  533. };
  534. }
  535. if (env.MEASURE) {
  536. const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
  537. const smp = new SpeedMeasurePlugin();
  538. appConfig = smp.wrap(appConfig);
  539. }
  540. module.exports = appConfig;