Advertisement
YarikHrom

Untitled

Mar 23rd, 2022
929
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Note: You must restart bin/webpack-dev-server for changes to take effect
  2. # @see https://rossta.net/blog/how-to-use-webpacker-yml.html
  3.  
  4. default: &default
  5.   source_path: app/javascript
  6.   source_entry_path: packs
  7.   public_root_path: public
  8.   public_output_path: packs
  9.   cache_path: tmp/cache/webpacker
  10.   webpack_compile_output: true
  11.  
  12.   # Additional paths webpack should lookup modules
  13.   # ['app/assets', 'engine/foo/app/assets']
  14.   resolved_paths: []
  15.  
  16.   # Reload manifest.json on all requests so we reload latest compiled packs
  17.   cache_manifest: false
  18.  
  19.   # Extract and emit a css file
  20.   extract_css: false
  21.  
  22.   static_assets_extensions:
  23.     - .jpg
  24.     - .jpeg
  25.     - .png
  26.     - .gif
  27.     - .tiff
  28.     - .ico
  29.     - .eot
  30.     - .otf
  31.     - .ttf
  32.     - .woff
  33.     - .woff2
  34.  
  35.   extensions:
  36.     - .tsx
  37.     - .ts
  38.     - .jsx
  39.     - .mjs
  40.     - .js
  41.     - .less
  42.     - .sass
  43.     - .scss
  44.     - .css
  45.     - .module.sass
  46.     - .module.scss
  47.     - .module.css
  48.     - .module.less
  49.     - .png
  50.     - .svg
  51.     - .gif
  52.     - .jpeg
  53.     - .jpg
  54.  
  55. development:
  56.   <<: *default
  57.   compile: true
  58.  
  59.   # Reference: https://webpack.js.org/configuration/dev-server/
  60.   dev_server:
  61.     https: false
  62.     host: localhost
  63.     port: 3035
  64.     public: localhost:3035
  65.     hmr: true
  66.     # Inline should be set to true if using HMR
  67.     inline: true
  68.     overlay: true
  69.     compress: true
  70.     disable_host_check: true
  71.     use_local_ip: false
  72.     quiet: false
  73.     headers:
  74.       "Access-Control-Allow-Origin": "*"
  75.     watch_options:
  76.       ignored: "**/node_modules/**"
  77.  
  78. test:
  79.   <<: *default
  80.   compile: true
  81.  
  82.   # Compile test packs to a separate directory
  83.   public_output_path: packs-test
  84.  
  85. production:
  86.   <<: *default
  87.  
  88.   # Production depends on precompilation of packs prior to booting for performance.
  89.   compile: false
  90.  
  91.   # Extract and emit a css file
  92.   extract_css: true
  93.  
  94.   # Cache manifest.json for performance
  95.   cache_manifest: true
  96.  
  97. webpacker.yml
  98. ----------------------------------
  99. process.env.NODE_ENV = process.env.NODE_ENV || 'development';
  100.  
  101. const environment = require('./environment');
  102.  
  103. module.exports = environment.toWebpackConfig();
  104.  
  105. development.js
  106. ---------------------------------
  107. const {environment} = require('@rails/webpacker');
  108.  
  109. const {graphql, less, moduleLess, svg} = require('./loaders');
  110.  
  111. environment.loaders.append('graphql', graphql);
  112. environment.loaders.append('less', less);
  113. environment.loaders.append('svg', svg);
  114. environment.loaders.append('less.module', moduleLess);
  115.  
  116. module.exports = environment;
  117.  
  118. environment.js
  119. -----------------------------------
  120. process.env.NODE_ENV = process.env.NODE_ENV || 'production';
  121.  
  122. const environment = require('./environment');
  123.  
  124. module.exports = environment.toWebpackConfig();
  125.  
  126. production.js
  127. ---------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement