The following HTML code
<!DOCTYPE html>
<html lang="en">
<body>
Greeting below:
<div id="time">
{{greetings}}
</div>
<script src='bundle.js'></script>
</body>
</html>
together with the entry.js file
// either the import or the require work
Vue = require('./vue.js')
//import Vue from './vue.js'
new Vue({
el: "#time",
data: {
greetings: "hello world"
}
})
and the webpack.config.js
module.exports = {
entry: './entry.js',
output: {
filename: 'bundle.js'
}
}
works fine (vue.js is locally downloaded from the site or a CDN).
I then tried to use the vue module installed via npm install vue --save-dev by changing entry.js to
import Vue from 'vue'
new Vue({
el: "#time",
data: {
greetings: "hello world"
}
})
This version does not work anymore: the whole <div> is not rendered (only Greeting below is displayed).
What should be done so that Vue.js can be used with webpack?
The Vue documentation mentions webpack a few times, but only in the context of components or production builds.
webpackand othernode/npmbaggage may no longer be necessary for simple apps: developers.google.com/web/fundamentals/primers/modules