├── .babelrc
├── .gitignore
├── README.md
├── globals.d.ts
├── package-lock.json
├── package.json
├── pages
├── home
│ ├── index.html
│ ├── index.ts
│ └── index.vue
└── test
│ ├── index.html
│ ├── index.ts
│ └── index.vue
├── tsconfig.json
├── vendors
├── public.ts
└── url.min.js
└── webpack.config.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["es2015", "stage-0"]
4 | ],
5 | "plugins": [
6 | "transform-runtime",
7 | [
8 | "component",
9 | {
10 | "libraryName": "element-ui",
11 | "styleLibraryName": "theme-chalk"
12 | }
13 | ]
14 | ]
15 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | build
3 | node_modules
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### vue+ts+element-ui+webpack project build
2 |
3 | #### Usage
4 |
5 | ```
6 | git clone
7 | npm install
8 | npm run start
9 | build: npm run prod
10 | ```
11 |
12 | #### Introduction
13 | ##### 此项目使用 webpack4 版本
14 | ##### 使用了基于类的 Vue 组件 vue-class-component 进行开发
15 | ##### 此项目为多页应用 非 SPA
--------------------------------------------------------------------------------
/globals.d.ts:
--------------------------------------------------------------------------------
1 | declare module '*.vue' {
2 | import Vue from 'vue'
3 | export default Vue
4 | }
5 |
6 | declare var $;
7 |
8 | declare function require(path: string): any;
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "profession-stars-web",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "mocha-webpack --webpack-config webpack.config.js test/**/*.spec.js",
8 | "start": "webpack-dev-server --inline --env=dev --progress --profile --colors",
9 | "prod": "rm -rf build && webpack --progress"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": ""
14 | },
15 | "keywords": [],
16 | "author": "",
17 | "license": "ISC",
18 | "dependencies": {
19 | "babel": "^6.23.0",
20 | "babel-core": "^6.25.0",
21 | "babel-loader": "^7.1.1",
22 | "babel-plugin-transform-runtime": "^6.23.0",
23 | "babel-preset-env": "^1.6.0",
24 | "babel-preset-es2015": "^6.24.1",
25 | "babel-preset-stage-0": "^6.24.1",
26 | "babel-runtime": "^6.26.0",
27 | "css-loader": "^0.28.4",
28 | "element-ui": "^2.4.6",
29 | "extract-text-webpack-plugin": "^3.0.0",
30 | "file-loader": "^2.0.0",
31 | "html-webpack-plugin": "^3.2.0",
32 | "jquery": "^3.2.1",
33 | "less": "^3.8.1",
34 | "less-loader": "^4.1.0",
35 | "mini-css-extract-plugin": "^0.4.2",
36 | "style-loader": "^0.18.2",
37 | "vue": "^2.5.17",
38 | "vue-class-component": "^6.2.0",
39 | "vue-loader": "^14.2.3",
40 | "vue-property-decorator": "^7.0.0",
41 | "vue-style-loader": "^3.1.2",
42 | "vue-template-compiler": "^2.5.17",
43 | "webpack": "^4.17.1",
44 | "webpack-cli": "^3.1.0",
45 | "webpack-dev-server": "^2.9.7"
46 | },
47 | "devDependencies": {
48 | "babel-plugin-component": "^0.10.0",
49 | "chai": "^4.1.2",
50 | "chalk": "^2.4.1",
51 | "coffeescript": "^2.3.1",
52 | "expose-loader": "^0.7.5",
53 | "friendly-errors-webpack-plugin": "^1.7.0",
54 | "mocha": "^5.2.0",
55 | "mocha-webpack": "^1.1.0",
56 | "node-notifier": "^5.2.1",
57 | "ts-loader": "^4.5.0",
58 | "typescript": "^3.0.1",
59 | "uglifyjs-webpack-plugin": "^0.4.6"
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/pages/home/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pages/home/index.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import 'element-ui/lib/theme-chalk/index.css';
3 | import ElementUI from 'element-ui'; // 不能使用 分模块导入 ‘element-ui’ ts 会报错,不知所以然。
4 |
5 | Vue.use(ElementUI)
6 |
7 | import index from './index.vue';
8 |
9 | window.onload = function(){
10 | var app = new Vue({
11 | el:"#cont",
12 | render: function(createElement: any){
13 | return createElement(index)
14 | }
15 | })
16 | }
--------------------------------------------------------------------------------
/pages/home/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ title }}
5 |
6 |
7 |
8 |
9 |
28 |
29 |
36 |
--------------------------------------------------------------------------------
/pages/test/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pages/test/index.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import 'element-ui/lib/theme-chalk/index.css';
3 | import ElementUI from 'element-ui'; // 不能使用 分模块导入 ‘element-ui’ ts 会报错,不知所以然。
4 |
5 | Vue.use(ElementUI)
6 |
7 | import index from './index.vue';
8 |
9 | window.onload = function(){
10 | var app = new Vue({
11 | el:"#cont",
12 | render: function(createElement: any){
13 | return createElement(index)
14 | }
15 | })
16 | }
--------------------------------------------------------------------------------
/pages/test/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ title }}
4 |
5 |
6 |
7 |
22 |
23 |
30 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "CommonJS",
5 | "moduleResolution": "node",
6 | "experimentalDecorators": true,
7 | "emitDecoratorMetadata": true,
8 | "lib": [
9 | "es2015", "dom"
10 | ]
11 | },
12 | "include": [
13 | "**/*.ts"
14 | ],
15 | "exclude": [
16 | "build",
17 | "node_modules"
18 | ]
19 | }
--------------------------------------------------------------------------------
/vendors/public.ts:
--------------------------------------------------------------------------------
1 | interface obj {
2 | type: string,
3 | url: string,
4 | data?: Object,
5 | async: boolean
6 | }
7 |
8 | function Ajax(obj: obj){
9 | this.type = obj.type
10 | this.url = obj.url
11 | this.data = obj.data || ''
12 | this.async = obj.async
13 | }
14 | Ajax.prototype.request = function(cb: (a: Object)=>string){
15 | var _ = this;
16 | $.ajax({
17 | type:_.type,
18 | url:_.url,
19 | data:_.data,
20 | async: _.async,
21 | timeout: 1000 * 10,
22 | success:function(result){
23 | cb(result);
24 | },
25 | error:function(err){
26 | cb(err);
27 | }
28 | })
29 | }
30 |
31 | export = Ajax; // ts写法 = module.exports = Ajax
--------------------------------------------------------------------------------
/vendors/url.min.js:
--------------------------------------------------------------------------------
1 | (function(window){var Url=window.Url={};function queryString(name,notDecoded){name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regex=new RegExp("[\\?&]"+name+"=([^]*)");var results=regex.exec(location.search);var encoded=null;if(results===null){return""}else{encoded=results[1].replace(/\+/g," ");if(notDecoded){return encoded}return decodeURIComponent(encoded)}}function parseQuery(search){var query={};if(typeof search!=="string"){search=window.location.search}search=search.replace(/^\?/g,"");if(!search){return{}}var a=search.split("&");var b=null;var i=0;var iequ;for(;i {
178 | if (severity !== 'error') return
179 |
180 | const error = errors[0]
181 | const filename = error.file && error.file.split('!').pop()
182 |
183 | notifier.notify({
184 | title: packageConfig.name,
185 | message: severity + ': ' + error.name,
186 | subtitle: filename || '',
187 | icon: path.join(__dirname, 'logo.png')
188 | })
189 | }
190 | },
191 | clearConsole: true,
192 | }))
193 |
194 | module.exports = config;
--------------------------------------------------------------------------------