Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

webpack.config.js 2.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  1. const path = require('path')
  2. const MiniCssExtractPlugin = require('mini-css-extract-plugin')
  3. const CopyWebpackPlugin = require('copy-webpack-plugin')
  4. const { EnvironmentPlugin } = require('webpack')
  5. const { reactBabelOptions } = require('./lib/react/babel')
  6. module.exports = {
  7. devtool: 'source-map', // this prevents webpack from using eval
  8. entry: './javascripts/index.js',
  9. output: {
  10. filename: 'index.js',
  11. path: path.resolve(__dirname, 'dist'),
  12. publicPath: '/dist'
  13. },
  14. module: {
  15. rules: [
  16. {
  17. test: /\.js$/,
  18. include: [
  19. path.resolve(__dirname, 'react')
  20. ],
  21. use: {
  22. loader: 'babel-loader',
  23. options: reactBabelOptions
  24. }
  25. },
  26. {
  27. test: /\.m?js$/,
  28. exclude: /(node_modules|bower_components|react)/,
  29. use: {
  30. loader: 'babel-loader',
  31. options: {
  32. exclude: /node_modules\/lodash/,
  33. presets: [
  34. ['@babel/preset-env', { targets: '> 0.25%, not dead' }]
  35. ],
  36. plugins: [
  37. '@babel/transform-runtime'
  38. ]
  39. }
  40. }
  41. },
  42. {
  43. test: /\.css$/i,
  44. use: ['style-loader', 'css-loader']
  45. },
  46. {
  47. test: /\.s[ac]ss$/i,
  48. use: [
  49. MiniCssExtractPlugin.loader,
  50. {
  51. loader: 'css-loader',
  52. options: {
  53. sourceMap: true,
  54. url: false
  55. }
  56. },
  57. {
  58. // Needed to resolve image url()s within @primer/css
  59. loader: 'resolve-url-loader',
  60. options: {}
  61. },
  62. {
  63. loader: 'sass-loader',
  64. options: {
  65. sassOptions: {
  66. includePaths: ['./stylesheets', './node_modules'],
  67. options: {
  68. sourceMap: true,
  69. sourceMapContents: false
  70. }
  71. }
  72. }
  73. }
  74. ]
  75. }
  76. ]
  77. },
  78. plugins: [
  79. new MiniCssExtractPlugin({
  80. filename: 'index.css'
  81. }),
  82. new CopyWebpackPlugin({
  83. patterns: [
  84. { from: 'node_modules/@primer/css/fonts', to: 'fonts' }
  85. ]
  86. }),
  87. new EnvironmentPlugin(['NODE_ENV'])
  88. ]
  89. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...