0

When I build with Vue/Cli, can I extract the files I want with the name I want?

main.js;

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import global from '../global.js';

createApp(App).use(store).use(router).mount('#app')

I already get an error when I open the commented field below. How can I take the appropriate action

vue.config.js;

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  productionSourceMap: false,
  //output: {
    //chunkFilename: (pathData) => {
      //return pathData.chunk.name === 'global' ? 'globalprivate.js' : '[chunkhash].js';
    //},
  //},
})

1 Answer 1

0

its works for me;

vue.config.js

const { defineConfig } = require("@vue/cli-service");
module.exports = defineConfig({
  transpileDependencies: true,
  productionSourceMap: false,
  configureWebpack: {
    entry: {
      global: ["./global.js"],
    },
    output: {
      filename: (pathData) => {
        return pathData.chunk.name === 'global' ? 'global.js' : '[name]_[id].js';
      },
    },
  },
});

and my dist folder;

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.