Created
May 17, 2017 02:19
-
-
Save pjchender/1c8672ecc0ea4cfde40bedace2c9e79d to your computer and use it in GitHub Desktop.
[Vue] Vue + Webpack 起手式
This file contains hidden or 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
<!-- app.vue --> | |
<template lang="html"> | |
<div class="message"> | |
{{ message }} | |
{{ ok }} | |
</div> | |
</template> | |
<script> | |
export default { | |
data () { | |
return { | |
message: 'Helo, Vue.js 2.0', | |
ok: 'Setup up is OK!!!!' | |
} | |
} | |
} | |
</script> | |
<style lang="css"> | |
.message { | |
color: pink; | |
font-size: 1.4em; | |
} | |
</style> |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Vue JS with Webpack</title> | |
</head> | |
<body> | |
<div id="app"> | |
<app></app> | |
</div> | |
<script src="dist/bundle.js"></script> | |
</body> | |
</html> |
This file contains hidden or 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
/* eslint no-unused-vars: "vm" */ | |
import Vue from 'vue' | |
import App from './app.vue' | |
new Vue({ | |
el: '#app', | |
components: { App } | |
}) |
This file contains hidden or 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
{ | |
"name": "vuecli-andy", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"build": "webpack", | |
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"babel-core": "^6.24.1", | |
"babel-loader": "^7.0.0", | |
"babel-plugin-transform-runtime": "^6.23.0", | |
"babel-preset-es2015": "^6.24.1", | |
"cross-env": "^5.0.0", | |
"css-loader": "^0.28.1", | |
"file-loader": "^0.11.1", | |
"style-loader": "^0.17.0", | |
"url-loader": "^0.5.8", | |
"vue-hot-reload-api": "^2.1.0", | |
"vue-loader": "^12.0.4", | |
"webpack": "^2.5.1", | |
"webpack-dev-server": "^2.4.5", | |
"webpack-merge": "^4.1.0" | |
} | |
} |
This file contains hidden or 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
const path = require('path') | |
const webpack = require('webpack') | |
module.exports = { | |
entry: path.join(__dirname, 'src', 'main'), | |
output: { | |
path: path.join(__dirname, 'dist'), | |
filename: 'bundle.js', | |
publicPath: '/dist' | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
loader: 'babel-loader', | |
exclude: /node_modules/ | |
}, | |
{ | |
test: /\.vue$/, | |
loader: 'vue-loader' | |
} | |
] | |
}, | |
resolve: { | |
extensions: ['.js', '.vue'], | |
alias: { | |
'vue$': 'vue/dist/vue.esm.js' | |
} | |
}, | |
plugins: [ | |
new webpack.HotModuleReplacementPlugin() | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment