Advertisement
Guest User

Untitled

a guest
Jan 18th, 2022
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. server.js ===========================
  2. "use strict.js"
  3.  
  4. const webpack = require('webpack');
  5. const WebpackDevServer = require('webpack-dev-server');
  6. const config = require('./webpack.config');
  7.  
  8. const compiler = webpack(config);
  9. const devServerOptions = {
  10. port: 3100,
  11. open: true,
  12. compress: true,
  13. allowedHosts: [
  14. 'dahut.ive',
  15. 'localhost'
  16. ],
  17. headers: {
  18. "Access-Control-Allow-Origin": "*",
  19. "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
  20. "Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
  21. }
  22. };
  23. const server = new WebpackDevServer(devServerOptions, compiler);
  24.  
  25. server.startCallback(() => {
  26. console.log("Starting server on http://localhost:3100");
  27. });
  28.  
  29. package.json =========================
  30. {
  31. "name": "npm",
  32. "version": "1.0.0",
  33. "description": "",
  34. "main": "index.js",
  35. "dependencies": {
  36. "mithril": "^2.0.0-rc.6",
  37. "uikit": "^3.6.22"
  38. },
  39. "devDependencies": {
  40. "css-loader": "^6.5.1",
  41. "exports-loader": "^0.7.0",
  42. "html-webpack-plugin": "^5.5.0",
  43. "less": "^3.13.1",
  44. "less-loader": "^4.1.0",
  45. "style-loader": "^0.23.1",
  46. "webpack": "^5.66.0",
  47. "webpack-cli": "^4.9.1",
  48. "webpack-dev-server": "^4.7.3"
  49. },
  50. "scripts": {
  51. "test": "echo \"Error: no test specified\" && exit 1",
  52. "start": "node server.js",
  53. "build": "webpack src/index.js -p"
  54. },
  55. "keywords": [],
  56. "author": "",
  57. "license": "ISC"
  58. }
  59.  
  60.  
  61. webpack.config.js ==========================
  62.  
  63. const path = require('path');
  64. const HtmlWebpackPlugin = require('html-webpack-plugin');
  65.  
  66. module.exports = {
  67. mode: 'development',
  68. output: {
  69. path: path.join(__dirname, 'dist'),
  70. filename: 'app.[contenthash].js',
  71. publicPath: './'
  72. },
  73. module: {
  74. rules: [
  75. {
  76. test: /\.css$/,
  77. use: [{
  78. loader: 'style-loader'
  79. }, {
  80. loader: 'style-loader'
  81. }]
  82. },
  83. {
  84. test: /\.less$/,
  85. use: [{
  86. loader: 'style-loader'
  87. }, {
  88. loader: 'css-loader'
  89. }, {
  90. loader: 'less-loader'
  91. }]
  92. }
  93. ]
  94. },
  95. plugins: [
  96. new HtmlWebpackPlugin({
  97. template: path.join(__dirname + '/index.html')
  98. })
  99. ]
  100. };
  101.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement