D
D
dimkaholodov2018-09-13 17:48:38
JavaScript
dimkaholodov, 2018-09-13 17:48:38

Webpack-dev-server not refreshing the page, why?

https://github.com/DmitriiKholodov/exmo.me-api.git
Good evening, there is a simple structure:

exmo.me-api/
├── src/
│        ├── exmo-api.js
│        └── index.js
├── node-modules/
│        ├──  ...
├── index.html
├── package.json
├── package-lock.json
├── webpack.config.js
├── README.md
├── LICENSE.md

package.json
{
  "name": "exmo.me-api",
  "version": "1.0.0",
  "description": "getting data from public exmo.me api to your project",
  "main": "script.js",
  "scripts": {
    "dev": "webpack-dev-server --mode development --open --watch",
    "build": "webpack --mode production"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/DmitriiKholodov/exmo.me-api.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/DmitriiKholodov/exmo.me-api/issues"
  },
  "homepage": "https://github.com/DmitriiKholodov/exmo.me-api#readme",
  "devDependencies": {
    "path": "^0.12.7",
    "webpack": "^4.18.0",
    "webpack-cli": "^3.1.0",
    "webpack-dev-server": "^3.1.8"
  },
  "dependencies": {}
}

connected webpack with the following config
webpack.config.js
let path = require('path');

let conf = {
  entry: path.resolve(__dirname, './src/index.js'),
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'main.js',
    publicPath: 'dist/'
  },
  devServer: {
      hot: true
  }
};

module.exports = conf;

exmo-api.js
'use strict'

const baseUrl = 'https://api.exmo.com/v1/' // {api_name}?{api_params}

function getData(url) {
  fetch(url)
    .then(function(response) {
      return response.json()
    })
    .then(function(data) {
    	  return data
    })
    .catch(alert)
}
  

const exmo = {}

exmo.ticker = function ticker() {
  const url = baseUrl + 'ticker'
  return getData(url) 
} // example - https://api.exmo.com/v1/ticker
exmo.trades = function trades(...pairs){
  const url = baseUrl + 'trades/' + '?pair=' + pairs
  return getData(url)
} // example - https://api.exmo.com/v1/trades/?pair=BTC_USD,BTC_EUR
exmo.order_book = function order_book(limit, ...pairs){
  const url = baseUrl + 'trades/' + '?pair=' + pairs + '&limit=' + limit
  return getData(url)
} // example - https://api.exmo.com/v1/order_book/?pair=BTC_USD,BTC_EUR&limit=1000
exmo.pair_settings = function pair_settings(){
  const url = baseUrl + 'pair_settings'
  return getData(url)
} // example - https://api.exmo.com/v1/pair_settings
exmo.currency = function currency(){
  const url = baseUrl + 'currency'
  return getData(url)
} // example - https://api.exmo.com/v1/currency

let v = function a(a,b) {
  return a + b
}

export default { v };

index.js
'use strict'

import v from './exmo-api';

let f = v(3,5)
alert("asd")
console.log(f);

As a result, when you run npm run dev, everything starts successfully, localhost opens, changes in / src are tracked (but the page does not reload).
in the console at startup, not everything is so smooth -
5b9a7771bf8b5955985606.png
everything else is not worked out
alert("asd")
console.log(f)

Advise something, never worked with it earlier. Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dimkaholodov, 2018-09-14
@dimkaholodov

when I run npm run build I get a working main.js with the result

console.log(f) 
alert("asd")

when running npm run dev there is console.log(f)neitheralert("asd")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question