webpack 2 - garevna/js-course GitHub Wiki

:briefcase: Упражнение 2

Создадим новый файл :pencil: promise.js в папке :open_file_folder: src

:pencil: promise.js
var promise = new Promise ( function ( resolve, reject ) {
    document.write ( 'Wait, pease...<br>' )
    setTimeout ( () => resolve ( "OK, you are here ?" ), 2000 )
})

export default promise
:pencil: index.js
import promise from './promise.js'

promise.then ( response =>
    document.querySelector ( '.sampleClass' )
        .innerText += response )

в Git Bush запустим команду webpack

Теперь откройте файл index.html в окне браузера