26
loading...
This website collects cookies to deliver better user experience
vue.config.js
const path = require('path');
module.exports = {
configureWebpack: {
resolve: {
alias: {
"~": path.resolve(__dirname)
}
},
},
css: {
loaderOptions: {
sass: {
additionalData: `
@import "@/assets/scss/_main.scss";
`
}
}
}
}
package.json
to build our lib...
"scripts": {
"build": "vue-cli-service build --target lib src/index.js",
},
...
src/index.js
file, it's where we imported all my components and prepare them to be imported when another project is using this package. You can check more about this here: Vue cookbookexport * from './components/inputs'
import * as inputs from './components/inputs'
const components = {
...inputs,
}
export function install (Vue) {
for (const [name, component] of Object.entries(components)) {
Vue.component(name, component)
}
}
const plugin = {
install
}
let GlobalVue = null;
if (typeof window !== "undefined") {
GlobalVue = window.Vue;
} else if (typeof global !== "undefined") {
// eslint-disable-next-line no-undef
GlobalVue = global.Vue
}
if (GlobalVue) {
GlobalVue.use(plugin);
}
export default plugin;
vue.config.js
inside configureWebpack key and it won't compile anymore....
externals: [
'dayjs',
'moment',
'ramda',
'sortablejs'
],
...