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

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

Comments

Loading...