Skip to content

Instantly share code, notes, and snippets.

@kenichi-odo
Last active October 10, 2018 07:36
Show Gist options
  • Save kenichi-odo/44ccc3ada8a4a7f1868c284d6096e3ed to your computer and use it in GitHub Desktop.
Save kenichi-odo/44ccc3ada8a4a7f1868c284d6096e3ed to your computer and use it in GitHub Desktop.
Visualforce上で動くTypeScript + Vue.jsをVisual Studio Codeで開発する ref: https://qiita.com/kenichi_odo/items/8fc18e6020a2e35318ea
<template>
<div>
{{text}}
<child-component>
</child-component>
</div>
</template>
<script>
import ChildComponent from './child-component.vue'
export default {
data() {
return { text: 'foobar' }
},
components: {
'child-component': ChildComponent
}
}
</script>
<template>
<input type="button"
:value="button_name"
@click="showAlert" />
</template>
<script>
export default {
data() {
return { button_name: 'foo' }
},
methods: {
showAlert(): void {
alert('bar')
}
}
}
</script>
brew cask update
brew cask install visual-studio-code
import Vue from 'vue'
import App from './app.vue'
new Vue({
el: '#app',
render: _ => _(App)
})
{
"devDependencies": {
"typescript": "^2.2.2",
"vue": "^2.2.6",
"vue-loader": "^11.3.4",
"vue-template-compiler": "^2.2.6",
"vue-ts-loader": "0.0.3",
"vue-typescript-import-dts": "^3.0.1",
"webpack": "^2.3.3",
"webpack-sfdc-deploy-plugin": "^1.1.9"
},
"scripts": {
"build-VueTest": "webpack --env.resource_name=VueTest",
"watch-VueTest": "webpack -w --env.resource_name=VueTest"
}
}
module.exports = {
username: 'user@test.com',
password: 'password',
token: ''
}
{
"compilerOptions": {
"module": "es2015",
"moduleResolution": "node",
"types": [
"vue-typescript-import-dts"
],
"allowSyntheticDefaultImports": true
}
}
<apex:page
sidebar="false"
showHeader="false"
standardStylesheets="false"
applyBodyTag="false"
applyHtmlTag="false"
docType="html-5.0">
<html>
<head>
<meta charset="UTF-8" />
</head>
<body style="margin: 0;">
<div id="app"></div>
<script src="{!URLFOR($Resource.VueTest, 'bundle.js')}"></script>
</body>
</html>
</apex:page>
var Webpack = require('webpack')
var SfdcDeployPlugin = require('webpack-sfdc-deploy-plugin')
module.exports = function (env_) {
return {
entry: './src/' + env_.resource_name + '/index.ts',
output: {
filename: './build/' + env_.resource_name + '/bundle.js'
},
devtool: 'source-map',
module: {
loaders: [
{ test: /\.ts$/, loader: 'vue-ts-loader' },
{ test: /\.vue$/, loader: 'vue-loader' }
]
},
resolve: { alias: { vue: 'vue/dist/vue.js' } },
plugins: [
new Webpack.LoaderOptionsPlugin({
options: {
resolve: { extensions: ['.ts', '.vue'] },
vue: {
loaders: { js: 'vue-ts-loader' }
}
}
}),
new SfdcDeployPlugin({
credentialsPath: __dirname + '/sfdc-org-config.js',
filesFolderPath: './build/' + env_.resource_name,
staticResourceName: env_.resource_name
})
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment