Vue-cli: Make final webpack.config.js can be acessed (import/require)

Created on 5 Feb 2018  路  3Comments  路  Source: vuejs/vue-cli

What problem does this feature solve?

There are cases when I need to use another cli (in my case are dotnet and start-storybook) for running some of my project. To run it properly, final webpack.config.js (sum of = vue.config.js + default vue config + all config of vue-cli-plugin-*) need to be acessed so it can be merged with another default webpack config (storybook) or integrate webpack hot-reload and its config into another server side framework.

What does the proposed API look like?

I can only think 2 solution for this:

1. Expose chainableConfig

So user can do something like:

const { chainableConfig } = require('@vue/cli')
const mergeWebpack = require('webpack-merge') 

// this is storybook way for extending config
module.exports = (baseConfig, env, defaultConfig) => mergeWebpack(chainableConfig.toConfig(), defaultConfig)

However, the problem with this approach is I can't merge it with another server side framework that use another programing language (in my case are ASP.NET Core using webpack-aspnet-middleware)

2. Unfortunately vue eject

Implement eject command to output the final config into a file. This way I can point exactly where webpack.config.js are in my ASP.NET startup module. However, to make it safe, every time server-side cli run/start/build then vue eject need to be executed first.

Most helpful comment

You can already access it as node_modules/@vue/cli-service/webpack.config.js. This file dynamically resolves to the same config used in your actual project.

All 3 comments

I'd +1 for this also, would like to avoid the kind of lock-in and troubles you get trying to make changes to a project that's been set up using something like laravel mix.

You can already access it as node_modules/@vue/cli-service/webpack.config.js. This file dynamically resolves to the same config used in your actual project.

We use the webpack config file to create aliases to our modules/folders.
How can we do it now? I think, if we do it in the node_modules, everytime we clone the project we will need to do it again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eladcandroid picture eladcandroid  路  3Comments

Akryum picture Akryum  路  3Comments

miyamoto-san picture miyamoto-san  路  3Comments

sanderswang picture sanderswang  路  3Comments

jgribonvald picture jgribonvald  路  3Comments