Transitioning From Browserify to Webpack with Vue.js

We currently use a combination of Grunt, vueify, and browserify for our build process. This setup builds our Single File Components and separates Vue into its own external file.

Due to various factors like vueify being unsupported and the need for async component loading, we are considering switching to Webpack.

However, I am struggling to wrap my head around adapting our current method for Webpack. I have shared our existing build process below and would appreciate any insights on how to make it work with Webpack. How can we configure Webpack to compile our *.vue.js files into pre-rendered JavaScript files? I'm finding it difficult to even get started... Any suggestions?

vueRuntime: {
    expand: true,
    cwd: 'node_modules/vue/dist/',
    src: 'vue.runtime.min.js',
    dest: 'js/rwd/libs',
    ext: '.js',
    extDot: 'first',
    options: {
        configure: b => b
            .require('vue')
            .transform(
                {global: true},
                envify({NODE_ENV: 'production'})
            )
            .bundle(),
        browserifyOptions: {
            debug: false
        }
    }
},
vue: {
    expand: true,
    cwd: 'js/rwd/',
    src: '**/*.vue.js',
    dest: 'js/rwd',
    ext: '.js',
    extDot: 'first',
    options: {
        configure: b => b
            .transform('vueify')
            .transform(
                {
                    global: true
                },
                envify({NODE_ENV: 'production'})
            )
            .external('vue')
            .bundle(),
        browserifyOptions: {
            debug: false
        }
    }
}

Below is an example of a *.vue.js file:

const Vue = require('vue');
const App = require('./something/components/Something.vue');

new Vue(App).$mount('#app-element-id');

Answer №1

After recently completing a migration to Vue + Webpack, I stumbled upon a blog post that was incredibly useful:

If you're looking for more examples, the vue-cli is another great resource. However, navigating through the generated boilerplate can be quite challenging due to the numerous node modules involved, each providing small pieces of configuration and relying on other modules. If you're aiming to create something customized or understand how everything fits together, it might end up causing more headaches than benefits.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The scope of JavaScript's dynamic object

Can created objects be utilized in a different scope? var iZ = 0; var pcs = {}; function Pc(_name, _os) //Constructor { this.name = _name; // Pc Name this.os = _os; //Pc Os this.ausgabe = function() { //Do something }; ...

Validation in Ajax Response

When receiving an object from my API call, I want to perform error checking before displaying the JSON data in my view. function response(oResponse) { if (oResponse && oResponse != null && typeof oResponse === "object" && oResponse.response ...

How to efficiently manage drop-down menus on a website using VBA specifically designed for Internet Explorer

I am a beginner in VBA and coding, seeking assistance from the community. The purpose of this VBA code is to automate the following steps: Open Internet Explorer Enter user ID and password to login Select the current date Select a specific option (X1) fr ...

Ajax loaded scripts are unable to access global variables

Index.html <script> let bar = 1; </script> This html page is being loaded multiple times on the page using AJAX: article.html <script> if (bar === 1) { // perform a task } // Error: bar is not defined </script> Bar is a simple ...

VueJS - oops! Looks like we hit a limit with the call stack size. The error occurred at VueComponent.onFocusin

I imported a dialog component into my Document.vue file and encountered an error when attempting to add the dialog. This issue was resolved when I removed a specific element from my code. Can someone provide assistance? Here is the added code: <templat ...

Exploring the intersecting viewports in three.js

I'm attempting to create a camera (GUI camera) that renders above the scene camera. My idea was to make the GUI camera have a transparent background, allowing for visibility through it. However, it's not working as expected. Here is how I define ...

vue utilize filtering to search through a nested array of objects within a parent array of objects

After making an API call, I receive JSON-formatted data with a specific structure like this: data = [ { name: 'John', school:[ { school_name: 'Harvard', date_attended: '2017-05-23' }, { schoo ...

How can Vue listen for a Vuex commit?

Is there a method to detect when a Vuex commit occurs without having to monitor specific property changes associated with the commit? Simply knowing if a commit has taken place? I am working on a Filter component that I plan to include in an NPM package. ...

Have you ever encountered issues with Promises.all not functioning properly within your vuex store?

I'm currently experiencing an unusual problem. In my Vue project, I have a Vuex store that is divided into different modules. I am trying to utilize Promise.all() to simultaneously execute two independent async Vuex actions in order to benefit from th ...

Vue.js - computed property not rendering in repeated list

It seems like the issue lies in the timing rather than being related to asynchronous operations. I'm currently iterating through an object and displaying a list of items. One of the values requires calculation using a method. While the direct values ...

Sending information from one Angular 2 component to another

As a newcomer to Angular 2, I am still in the process of understanding its functionalities. Currently, I have two components: 1) List Component This component is responsible for displaying all the products in a store and performing various functions. @C ...

Adjusting the zoom level in leaflet.js ImageOverlay will cause the marker

Using ImageOverlay to display an image as a map with Leaflet.js, but encountering issues with marker positions shifting when changing the zoom level. Followed instructions from this tutorial, and you can find a code pen example here. // Code for markers ...

Image uploads are being interrupted by redirection

After submitting a form, I want the user to be redirected to another page. However, I am facing an issue with the redirection logic in my code. Although I am using window.location.href for redirection, it seems to interfere with the image uploading process ...

Storing data in cache and refreshing another object for a chart does not function properly

When working in my Controller, I am retrieving data from a $resource object that is stored in a caching service. $scope.data = myService.query(); //myService caches the response. Within the same controller, I am setting up the configuration for a chart ( ...

Processing requests through Axios and Express using the methods GET, POST, PUT, and DELETE

When working with express router and Axios (as well as many other frameworks/APIs), the use of GET/POST/PUT/DELETE methods is common. Why are these methods specified, and what are their differences? I understand that a GET request is used to retrieve dat ...

retrieving form data from a submit button using objects in PHP

I am using objects to fetch a form (including a submit button) from another page. However, I am struggling to extract the POSTED information from that submit button and believe that AJAX might be necessary. Here is an example: Page 1 initiates a call to ...

Instructions for displaying a React component in the <main> element when employing react-burger-menu

Check out my code here. Utilizing react-burger-menu has allowed me to successfully implement the sidebar feature. The sidebar functionality is working as expected. My current challenge involves figuring out how to open the content for Home or GG within ...

No values are being assigned to the array elements in the Node.js application

I've been struggling with an issue in my Express project for a day now. I can't seem to push some data into an array element. Let me walk you through my code and the data involved. Here is the result data retrieved from MongoDB: result = { n ...

Exploring Vue.js: Leveraging External JavaScript/JQuery Functions

I am currently working on developing a lightbox/modal feature using Vue.js. After making significant progress, I have encountered the need to utilize existing functions from another Javascript/Jquery file. Due to the complexity of these functions, rewritin ...

Utilizing Redux state within _app.tsx in NextJS: A comprehensive guide

This snippet of code pertains to my _app.tsx file import '../styles/globals.css' import AppNav from '../components/AppNav' import type { AppProps } from 'next/app' import { store } from '../store' import { Provider } ...