25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 년 전
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #Browsersync - Proxy example + injecting custom css file
  2. ## Installation/Usage:
  3. To try this example, follow these 4 simple steps.
  4. **Step 1**: Clone this entire repo
  5. ```bash
  6. $ git clone https://github.com/Browsersync/recipes.git bs-recipes
  7. ```
  8. **Step 2**: Move into the directory containing this example
  9. ```bash
  10. $ cd bs-recipes/recipes/proxy.custom-css
  11. ```
  12. **Step 3**: Install dependencies
  13. ```bash
  14. $ npm install
  15. ```
  16. **Step 4**: Run the example
  17. ```bash
  18. $ npm start
  19. ```
  20. ### Additional Info:
  21. To see the live-updating and CSS injecting, simply perform changes to `app/static/_custom.css`
  22. ### Preview of `app.js`:
  23. ```js
  24. /**
  25. * Require Browsersync
  26. */
  27. var browserSync = require('browser-sync').create();
  28. /**
  29. * Run Browsersync with server config
  30. * You can use an arrays for files to specify multiple files
  31. */
  32. browserSync.init({
  33. proxy: "example.com",
  34. serveStatic: ["app/static"],
  35. files: "app/static/_custom.css",
  36. snippetOptions: {
  37. rule: {
  38. match: /<\/head>/i,
  39. fn: function (snippet, match) {
  40. return '<link rel="stylesheet" type="text/css" href="/_custom.css"/>' + snippet + match;
  41. }
  42. }
  43. }
  44. });
  45. ```