[Vuejs]-What is wrong with the export of my npm packaged vue component?

0👍

You are using name export, so in order to use the test function you should import it as so:

import {test} from '../../fomantic-ui-vue/dist/main.js';

If you want to use it with a dot notation the in your main.js the export should be an object with the each key referencing on of the functions:

...
const myTestFunc = () => 'test';
const aComponent = () => Vue.component(..);

export default {
   test: myTestFunc,
   component: aComponent
}

Hope it helps

0👍

The solution is to add library and libraryTarget in the webpack.config.js:

module.exports = {
  entry: './src/index.js',
  output: {
    library: 'fomantic-ui-vue',
    libraryTarget: 'umd',
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist'),
  },

Leave a comment