I'm trying to understand how to build a component with Gulp. At this time, I have a Vue component that looks like this:
my-component.vue
<template>
<div class="foo">
</div>
</template>
<script>
export default {
data() {
return {};
},
props: {
message: {
type: String,
default: ''
}
},
methods: {
display: function() {
alert(this.message);
}
},
};
</script>
I'm building this component via Gulp. My gulpfile.js has the following:
gulpfile.js
const gulp = require('gulp');
const vueify = require('gulp-vueify2');
gulp.task('default', ['build']);
gulp.task('build', function() {
return gulp.src('./src/my-component.vue')
.pipe(vueify())
.pipe(gulp.dest('./deploy'))
;
});
When I run this, I have my-component.js in the "deploy" directory. When I view that file, I see the following at the top of my-component.js
var __vueify_style_dispose__ = require("vueify/lib/insert-css")
I'm trying to load the component in an HTML file like this:
<script type="text/javascript" src="./my-component.js"></script>
The script loads. However, there is an error in the console that says:
Uncaught ReferenceError: require is not defined
How do I build the component such that require is not used? Is there a way to do this? If so, how?