Created
December 28, 2020 20:52
-
-
Save justinturpin/816ac35af8fd9a86a43d83eda514bd53 to your computer and use it in GitHub Desktop.
Working Vue and Rollup JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<script type="module" src="/static/bundle.js"></script> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createApp } from 'vue'; | |
import Posts from './Posts.vue'; | |
createApp(Posts).mount("#createpost-container") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<h1>Hello {{ name }}</h1> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { name: 'Jane Doe' } | |
} | |
} | |
</script> | |
<style scoped> | |
h1 { | |
color: red; | |
} | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import resolve from '@rollup/plugin-node-resolve'; | |
import replace from '@rollup/plugin-replace'; | |
import commonjs from '@rollup/plugin-commonjs'; | |
import alias from '@rollup/plugin-alias'; | |
import vue from 'rollup-plugin-vue'; | |
import css from 'rollup-plugin-css-only' | |
// import postcss from 'rollup-plugin-postcss' | |
// import { terser } from 'rollup-plugin-terser'; | |
let nodeEnv = process.env.ROLLUP_WATCH ? 'development' : 'production'; | |
export default [ | |
{ | |
input: 'js/index.js', | |
output: [ | |
{ | |
file: "static/bundle.js", | |
format: 'esm', | |
sourcemap: true, | |
} | |
], | |
plugins: [ | |
replace({ | |
'process.env.NODE_ENV': JSON.stringify( nodeEnv ), | |
'__VUE_PROD_DEVTOOLS__': JSON.stringify(true), | |
'__VUE_OPTIONS_API__': JSON.stringify(true), | |
}), | |
alias({ | |
entries: [ | |
{ find: 'vue', replacement: 'vue/dist/vue.esm-bundler.js' } | |
] | |
}), | |
css(), | |
vue(), | |
resolve({ | |
browser: true, | |
}), | |
commonjs(), | |
] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment