Browse Source

Merge 073165704f into d682e25643

pull/183/merge
zhangdichn 8 years ago
committed by GitHub
parent
commit
f4239af4dc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 35
      README.md
  2. 8
      meta.json
  3. 7
      template/.babelrc
  4. 9
      template/.editorconfig
  5. 6
      template/.gitignore
  6. 20
      template/README.md
  7. 19
      template/index.html
  8. 52
      template/package.json
  9. 70
      template/src/App.vue
  10. BIN
      template/src/assets/logo.png
  11. 22
      template/src/main.js
  12. 3
      template/src/pages/index.vue
  13. 3
      template/src/pages/test.vue
  14. 13
      template/src/route.config.js
  15. 60
      template/webpack.base.conf.js
  16. 111
      template/webpack.config.js
  17. 33
      template/webpack.dev.conf.js
  18. 5273
      template/yarn.lock

35
README.md

@ -1,33 +1,2 @@
# webpack-simple
> A simple Vue 2.0 Webpack & `vue-loader` setup for quick prototyping. Note this template is not suitable for production - for that you may want to use the [full webpack template](https://github.com/vuejs-templates/webpack).
> This template is Vue 2.0 compatible. For Vue 1.x use this command: `vue init webpack-simple#1.0 my-project`
### Usage
This is a project template for [vue-cli](https://github.com/vuejs/vue-cli).
``` bash
$ npm install -g vue-cli
$ vue init webpack-simple my-project
$ cd my-project
$ npm install
$ npm run dev
```
### What's Included
- `npm run dev`: Webpack + `vue-loader` with proper config for source maps & hot-reload.
- `npm run build`: build with HTML/CSS/JS minification.
For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader). Also check out the [breaking changes in vue-loader@9.0.0](https://github.com/vuejs/vue-loader/releases/tag/v9.0.0).
### Fork It And Make Your Own
You can fork this repo to create your own boilerplate, and use it with `vue-cli`:
``` bash
vue init username/repo my-project
```
# lantern-simple-template
lantern模版

8
meta.json

@ -21,10 +21,10 @@
"default": "MIT"
},
"sass": {
"type": "confirm",
"message": "Use sass?",
"default": false
"type": "confirm",
"message": "Use sass?",
"default": false
}
},
"completeMessage": "{{#inPlace}}To get started:\n\n npm install\n npm run dev{{else}}To get started:\n\n cd {{destDirName}}\n npm install\n npm run dev{{/inPlace}}"
}
}

7
template/.babelrc

@ -1,6 +1,3 @@
{
"presets": [
["env", { "modules": false }],
"stage-3"
]
}
"presets": ["es2015", "stage-3"]
}

9
template/.editorconfig

@ -1,9 +0,0 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

6
template/.gitignore

@ -1,12 +1,12 @@
node_modules
.DS_Store
node_modules/
dist/
npm-debug.log
yarn-error.log
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sln

20
template/README.md

@ -1,18 +1,2 @@
# {{ name }}
> {{ description }}
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
```
For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader).
# lantern-simple-template
lantern模版

19
template/index.html

@ -1,11 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{ name }}</title>
</head>
<body>
<div id="app"></div>
<script src="/dist/build.js"></script>
</body>
</html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>lantern</title>
</head>
<body>
<div id="app"></div>
</body>
</html>

52
template/package.json

@ -1,37 +1,35 @@
{
"name": "{{ name }}",
"description": "{{ description }}",
"name": "lantern-template",
"version": "1.0.0",
"author": "{{ author }}",
"license": "{{ license }}",
"private": true,
"description": "lantern模版",
"main": "index.js",
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
"tempinit": "yarn || npm install",
"dev": "cross-env webpack-dev-server --open --hot --inline --host --port 8010 --config ./build/webpack.dev.conf.js"
},
"dependencies": {
"vue": "^2.5.11"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"file-loader": "^1.1.4",
{{#sass}}
"node-sass": "^4.5.3",
"sass-loader": "^6.0.6",
{{/sass}}
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.9.1"
"cross-env": "^5.1.3",
"css-loader": "^0.28.9",
"extract-text-webpack-plugin": "^3.0.2",
"html-webpack-plugin": "^2.30.1",
"less": "^2.7.3",
"less-loader": "^4.0.5",
"style-loader": "^0.20.2",
"vue-loader": "^13.7.0",
"vue-style-loader": "^3.0.3",
"vue-template-compiler": "^2.5.13",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.11.0",
"webpack-merge": "^4.1.1"
},
"dependencies": {
"lantern-ui": "^0.9.21",
"vue": "^2.5.13",
"vue-router": "^3.0.1"
}
}

70
template/src/App.vue

@ -1,21 +1,27 @@
<template>
<div id="app">
<img src="./assets/logo.png">
<h1>\{{ msg }}</h1>
<h2>Essential Links</h2>
<ul>
<li><a href="https://vuejs.org" target="_blank">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank">Twitter</a></li>
</ul>
<h2>Ecosystem</h2>
<ul>
<li><a href="http://router.vuejs.org/" target="_blank">vue-router</a></li>
<li><a href="http://vuex.vuejs.org/" target="_blank">vuex</a></li>
<li><a href="http://vue-loader.vuejs.org/" target="_blank">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank">awesome-vue</a></li>
</ul>
<lt-layout class="ltdemo-wrap" :width="layoutWidth">
<lt-header class="ltdemo-header" height="60px">
<div class="header-nav">
<span>Lantern</span>
</div>
</lt-header>
<lt-main class="ltdemo-main" height="100%">
<div class="main-wrap">
<lt-layout class="main-wrap-layout" :isRow="mainLayoutIsRow">
<lt-aside width="300px">
<lt-menu>
<lt-menu-item :href="'/'">index</lt-menu-item>
<lt-menu-item :href="'/test'">测试</lt-menu-item>
</lt-menu>
</lt-aside>
<lt-main height="100%">
<router-view></router-view>
</lt-main>
</lt-layout>
</div>
</lt-main>
</lt-layout>
</div>
</template>
@ -24,37 +30,13 @@ export default {
name: 'app',
data () {
return {
msg: 'Welcome to Your Vue.js App'
layoutWidth: '100%',
mainLayoutIsRow: true
}
}
}
</script>
<style>
</style>
<style{{#sass}} lang="scss"{{/sass}}>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

BIN
template/src/assets/logo.png

Before

Width: 200  |  Height: 200  |  Size: 6.7 KiB

22
template/src/main.js

@ -1,7 +1,21 @@
import Vue from 'vue'
import App from './App.vue'
import Vue from 'vue';
import App from './app.vue';
import VueRouter from 'vue-router';
import Lantern from 'lantern-ui';
import routes from './route.config.js';
import 'lantern-ui/lib/lantern.css';
Vue.use(VueRouter);
const router = new VueRouter({
mode: 'history',
base: __dirname,
routes: routes
})
Vue.use(Lantern);
new Vue({
el: '#app',
render: h => h(App)
})
render: h => h(App),
router: router
});

3
template/src/pages/index.vue

@ -0,0 +1,3 @@
<template>
<div>index page</div>
</template>

3
template/src/pages/test.vue

@ -0,0 +1,3 @@
<template>
<div>test page</div>
</template>

13
template/src/route.config.js

@ -0,0 +1,13 @@
import index from './pages/index.vue';
import test from './pages/test.vue';
export default [
{
path: '/',
component: index
},
{
path: '/test',
component: test
}
]

60
template/webpack.base.conf.js

@ -0,0 +1,60 @@
const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin")
function resolve(dir) {
return path.join(__dirname, '..', dir);
}
const baseConfig = {
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
'src': resolve('/src')
}
},
module: {
rules: [
{
test: /\.vue$/,
use: {
loader: 'vue-loader',
options: {
loaders: {
css: ExtractTextPlugin.extract({
use: 'css-loader',
fallback: 'vue-style-loader'
}),
less: ExtractTextPlugin.extract({
use: ['css-loader', 'less-loader'],
fallback: 'vue-style-loader'
})
}
}
}
},
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg|ttf)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: 'css-loader',
fallback: 'style-loader'
})
}
]
},
}
module.exports = baseConfig;

111
template/webpack.config.js

@ -1,111 +0,0 @@
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
},{{#sass}}
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader'
],
},
{
test: /\.sass$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
],
},
{{/sass}}
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
{{#sass}}
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
// the "scss" and "sass" values for the lang attribute to the right configs here.
// other preprocessors should work out of the box, no loader config like this necessary.
'scss': [
'vue-style-loader',
'css-loader',
'sass-loader'
],
'sass': [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
]
{{/sass}}
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}

33
template/webpack.dev.conf.js

@ -0,0 +1,33 @@
const path = require('path');
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const webpackbaseConf = require('./webpack.base.conf.js');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const devConfig = {
entry: {
main: './src/main.js',
vendors: ['vue', 'vue-router']
},
output: {
path: path.join(__dirname, './dist'),
filename: '[name].js',
publicPath: '',
chunkFilename: '[name].chunk.js'
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
}),
new ExtractTextPlugin("style.css")
],
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true,
public: 'localhost:8010'
}
}
module.exports = webpackMerge(webpackbaseConf, devConfig);

5273
template/yarn.lock
File diff suppressed because it is too large
View File

Loading…
Cancel
Save