diff --git a/BotSharp.UI/.babelrc b/BotSharp.UI/.babelrc deleted file mode 100644 index 9897749d..00000000 --- a/BotSharp.UI/.babelrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "presets": [ - ["es2015", { "modules": false }] - ] -} diff --git a/BotSharp.UI/.gitignore b/BotSharp.UI/.gitignore deleted file mode 100644 index 7ae644ce..00000000 --- a/BotSharp.UI/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.idea -.idea/ -.DS_Store -node_modules/ -.project -dist -dist/* -src/config/*.tmp -src/config/env.js -/index.html -/index_prod.html \ No newline at end of file diff --git a/BotSharp.UI/LICENSE b/BotSharp.UI/LICENSE deleted file mode 100644 index 6e8e0485..00000000 --- a/BotSharp.UI/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2016 iView - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/BotSharp.UI/README.md b/BotSharp.UI/README.md deleted file mode 100644 index 901e400a..00000000 --- a/BotSharp.UI/README.md +++ /dev/null @@ -1,18 +0,0 @@ -BotSharp Web Console -=== - -## How to install -#### Download source code -````sh -git clone https://github.com/SciSharp/BotSharp -```` -#### Run node.js server -````sh -npm install -npm run init -npm run dev -```` -#### Deploy web portal -````sh -npm run build -```` \ No newline at end of file diff --git a/BotSharp.UI/package.json b/BotSharp.UI/package.json deleted file mode 100644 index f439bdfa..00000000 --- a/BotSharp.UI/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "iview-project", - "version": "2.0.0", - "description": "A base project with Vue.js2、Vue-Router、webpack2 and with iView2.", - "main": "index.js", - "scripts": { - "init": "webpack --progress --config webpack.dev.config.js", - "dev": "webpack-dev-server --content-base ./ --open --inline --hot --compress --history-api-fallback --config webpack.dev.config.js", - "build": "webpack --progress --hide-modules --config webpack.prod.config.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/iview/iview-project.git" - }, - "author": "Aresn", - "license": "MIT", - "dependencies": { - "axios": "^0.16.2", - "iview": "^2.14.3", - "localStorage": "^1.0.4", - "vue": "^2.6.8", - "vue-avatar-editor": "^1.0.4", - "vue-input-tag": "0.0.16", - "vue-localstorage": "^0.3.0", - "vue-router": "^2.8.1", - "vue-typer": "^1.2.0", - "vuex": "^2.5.0" - }, - "devDependencies": { - "autoprefixer-loader": "^2.0.0", - "babel": "^6.23.0", - "babel-core": "^6.26.3", - "babel-loader": "^6.2.4", - "babel-plugin-transform-runtime": "^6.12.0", - "babel-preset-es2015": "^6.24.1", - "babel-runtime": "^6.26.0", - "css-loader": "^0.23.1", - "extract-text-webpack-plugin": "^2.0.0", - "file-loader": "^0.8.5", - "html-loader": "^0.3.0", - "html-webpack-plugin": "^2.30.1", - "less": "^2.7.3", - "less-loader": "^2.2.3", - "style-loader": "^0.13.1", - "url-loader": "^0.5.7", - "vue-hot-reload-api": "^1.3.3", - "vue-html-loader": "^1.2.3", - "vue-loader": "^11.0.0", - "vue-style-loader": "^1.0.0", - "vue-template-compiler": "^2.6.8", - "webpack": "^2.2.1", - "webpack-dev-server": "^2.11.3", - "webpack-merge": "^3.0.0" - }, - "bugs": { - "url": "https://github.com/iview/iview-project/issues" - }, - "homepage": "https://www.iviewui.com" -} diff --git a/BotSharp.UI/src/app.vue b/BotSharp.UI/src/app.vue deleted file mode 100644 index 34c14d58..00000000 --- a/BotSharp.UI/src/app.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - diff --git a/BotSharp.UI/src/components/vue-avatar-scale.vue b/BotSharp.UI/src/components/vue-avatar-scale.vue deleted file mode 100644 index 9c6fb663..00000000 --- a/BotSharp.UI/src/components/vue-avatar-scale.vue +++ /dev/null @@ -1,48 +0,0 @@ - - \ No newline at end of file diff --git a/BotSharp.UI/src/components/vue-avatar.vue b/BotSharp.UI/src/components/vue-avatar.vue deleted file mode 100644 index 829e0b51..00000000 --- a/BotSharp.UI/src/components/vue-avatar.vue +++ /dev/null @@ -1,428 +0,0 @@ - - - \ No newline at end of file diff --git a/BotSharp.UI/src/config/config.js b/BotSharp.UI/src/config/config.js deleted file mode 100644 index 9453ea59..00000000 --- a/BotSharp.UI/src/config/config.js +++ /dev/null @@ -1,8 +0,0 @@ -import Env from './env'; - -let config = { - env: Env, - baseURL: (Env == 'development' ? `http://localhost:3112` : `http://localhost:3112`), - testAccount: {username: `support@botsharp.io`, password: (Env == 'development' ? `botsharp` : ``)} -}; -export default config; \ No newline at end of file diff --git a/BotSharp.UI/src/favicon.ico b/BotSharp.UI/src/favicon.ico deleted file mode 100644 index b150f5f4..00000000 Binary files a/BotSharp.UI/src/favicon.ico and /dev/null differ diff --git a/BotSharp.UI/src/images/bot.png b/BotSharp.UI/src/images/bot.png deleted file mode 100644 index 966951e7..00000000 Binary files a/BotSharp.UI/src/images/bot.png and /dev/null differ diff --git a/BotSharp.UI/src/images/icons/SMS.png b/BotSharp.UI/src/images/icons/SMS.png deleted file mode 100644 index e20c127b..00000000 Binary files a/BotSharp.UI/src/images/icons/SMS.png and /dev/null differ diff --git a/BotSharp.UI/src/images/icons/Skype_t.png b/BotSharp.UI/src/images/icons/Skype_t.png deleted file mode 100644 index 156054b1..00000000 Binary files a/BotSharp.UI/src/images/icons/Skype_t.png and /dev/null differ diff --git a/BotSharp.UI/src/images/icons/Slack_Icon.png b/BotSharp.UI/src/images/icons/Slack_Icon.png deleted file mode 100644 index edf63438..00000000 Binary files a/BotSharp.UI/src/images/icons/Slack_Icon.png and /dev/null differ diff --git a/BotSharp.UI/src/images/icons/Twitter.ico b/BotSharp.UI/src/images/icons/Twitter.ico deleted file mode 100644 index be3ca23f..00000000 Binary files a/BotSharp.UI/src/images/icons/Twitter.ico and /dev/null differ diff --git a/BotSharp.UI/src/images/icons/facebook-messenger.svg b/BotSharp.UI/src/images/icons/facebook-messenger.svg deleted file mode 100644 index c2f92f73..00000000 --- a/BotSharp.UI/src/images/icons/facebook-messenger.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/BotSharp.UI/src/images/icons/logo-kik.png b/BotSharp.UI/src/images/icons/logo-kik.png deleted file mode 100644 index 0bdcbcfe..00000000 Binary files a/BotSharp.UI/src/images/icons/logo-kik.png and /dev/null differ diff --git a/BotSharp.UI/src/images/icons/logo-twilio.png b/BotSharp.UI/src/images/icons/logo-twilio.png deleted file mode 100644 index 9927d2ef..00000000 Binary files a/BotSharp.UI/src/images/icons/logo-twilio.png and /dev/null differ diff --git a/BotSharp.UI/src/images/icons/user.png b/BotSharp.UI/src/images/icons/user.png deleted file mode 100644 index a129aaa1..00000000 Binary files a/BotSharp.UI/src/images/icons/user.png and /dev/null differ diff --git a/BotSharp.UI/src/images/icons/website.png b/BotSharp.UI/src/images/icons/website.png deleted file mode 100644 index 026c837d..00000000 Binary files a/BotSharp.UI/src/images/icons/website.png and /dev/null differ diff --git a/BotSharp.UI/src/images/icons/wechat.png b/BotSharp.UI/src/images/icons/wechat.png deleted file mode 100644 index a7567fa0..00000000 Binary files a/BotSharp.UI/src/images/icons/wechat.png and /dev/null differ diff --git a/BotSharp.UI/src/images/logo.png b/BotSharp.UI/src/images/logo.png deleted file mode 100644 index defe10f9..00000000 Binary files a/BotSharp.UI/src/images/logo.png and /dev/null differ diff --git a/BotSharp.UI/src/images/user.png b/BotSharp.UI/src/images/user.png deleted file mode 100644 index 966951e7..00000000 Binary files a/BotSharp.UI/src/images/user.png and /dev/null differ diff --git a/BotSharp.UI/src/images/wakeup.jpg b/BotSharp.UI/src/images/wakeup.jpg deleted file mode 100644 index 5d6ba5b3..00000000 Binary files a/BotSharp.UI/src/images/wakeup.jpg and /dev/null differ diff --git a/BotSharp.UI/src/libs/http-common.js b/BotSharp.UI/src/libs/http-common.js deleted file mode 100644 index f60ee2ea..00000000 --- a/BotSharp.UI/src/libs/http-common.js +++ /dev/null @@ -1,48 +0,0 @@ -import axios from 'axios'; -import storage from 'localStorage'; -import config from '../config/config'; -import iView from 'iview'; - -export const HTTP = axios.create({ - baseURL: config.baseURL, - withCredentials: true -}) - -HTTP.interceptors.request.use(function (config) { - // Do something before request is sent - config.headers.common['Authorization'] = 'Bearer ' + localStorage.getItem('token'); - return config; - }, function (error) { - // Do something with request error - return Promise.reject(error); -}); - -HTTP.interceptors.response.use(null, function(error) { - let response = error.response; - - if(response == undefined) { - iView.Message.error(error.message); - return Promise.reject(error.message); - } - - let status = response.status; - - if (status === 400) { - iView.Message.error(response.data); - /*Object.keys(response.data).forEach(function(key) { - iView.Message.error(response.data[key][0]); - });*/ - } else if (status === 401) { - iView.Message.error("Unauthorized user!"); - } else if (status === 404) { - if(response.request.responseURL.indexOf('login?ReturnUrl=') > 0) { - status = iView.Message.error("Login again"); - return; - } - iView.Message.error("Not found."); - } else { - iView.Message.error(response.statusText); - } - - return Promise.reject(response.statusText); -}); \ No newline at end of file diff --git a/BotSharp.UI/src/libs/util.js b/BotSharp.UI/src/libs/util.js deleted file mode 100644 index 5e9b3ed9..00000000 --- a/BotSharp.UI/src/libs/util.js +++ /dev/null @@ -1,32 +0,0 @@ -let util = { - -}; -util.title = function (title) { - title = title ? title + ' - Home' : 'iView project'; - window.document.title = title; -}; - -util.getSelectionText = function () { - var text = ""; - var activeEl = document.activeElement; - var activeElTagName = activeEl ? activeEl.tagName.toLowerCase() : null; - if ( - (activeElTagName == "textarea" || activeElTagName == "input") && - /^(?:text|search|password|tel|url)$/i.test(activeEl.type) && - (typeof activeEl.selectionStart == "number") - ) { - text = activeEl.value.slice(activeEl.selectionStart, activeEl.selectionEnd); - } else if (window.getSelection) { - text = window.getSelection().toString(); - } - return text; -} - - -//This prototype function allows you to remove even array from array -Array.prototype.remove = function (val) { - var i = this.indexOf(val); - return i > -1 ? this.splice(i, 1) : []; -}; - -export default util; \ No newline at end of file diff --git a/BotSharp.UI/src/main.js b/BotSharp.UI/src/main.js deleted file mode 100644 index 41e08fef..00000000 --- a/BotSharp.UI/src/main.js +++ /dev/null @@ -1,107 +0,0 @@ -import Vue from 'vue'; -import Vuex from 'vuex' -import iView from 'iview'; -import VueRouter from 'vue-router'; -import Routers from './router'; -import config from './config/config'; -import VueLocalStorage from 'vue-localstorage'; -import {HTTP} from './libs/http-common'; - -import Util from './libs/util'; -import App from './app.vue'; - -import 'iview/dist/styles/iview.css'; - -Vue.use(Vuex) -Vue.use(VueRouter); -Vue.use(iView); -// use it via this.$ls -Vue.use(VueLocalStorage, {name: 'ls'}); -Vue.prototype.$ajax = HTTP; -Vue.prototype.$config = config; -Vue.prototype.$util = Util; - -// router config -const RouterConfig = { - mode: 'history', - routes: Routers -}; -const router = new VueRouter(RouterConfig); - -router.beforeEach((to, from, next) => { - iView.LoadingBar.start(); - Util.title(to.meta.title); - next(); -}); - -router.afterEach((to, from, next) => { - iView.LoadingBar.finish(); - window.scrollTo(0, 0); -}); - -// Global status management -const store = new Vuex.Store({ - state: { - // current agent - agentId: null, - agent: {id: null, name: null, avatar: null}, - agents: [], - // user status - user: {id: null, name: null, avatar: null}, - conversation: {id: null} - }, - getters: { - user: state => { - if(!state.user.name){ - state.user=JSON.parse(localStorage.getItem('user')); - }; - return state.user; - } - }, - mutations: { - setAgentId(state, agentId) { - state.agentId = agentId; - HTTP.get('/v1/agents/' + agentId) - .then(response => { - state.agent = response.data; - }); - }, - refreshAgents(state, agents) { - if(!agents){ - HTTP.get('/v1/Agents/MyAgents') - .then(response => { - if(response.data.length > 0) { - state.agents = response.data; - - state.agentId = response.data[0].id; - HTTP.get('/v1/agents/' + state.agentId) - .then(response => { - state.agent = response.data; - }); - } - }); - } else { - state.agents = agents; - setAgentId(agents[0].id); - } - }, - authenticated(state, token) { - localStorage.setItem('token', token); - router.push('/agent/agents'); - HTTP.get('/account', { baseURL: config.baseURL }) - .then(response => { - state.user = response.data; - localStorage.setItem('user', JSON.stringify(response.data)); - router.push('/agent/agents'); - }); - } - } -}) - -new Vue({ - el: '#app', - router: router, - // inject global status to vue instance - store: store, - render: h => h(App) -}); diff --git a/BotSharp.UI/src/router.js b/BotSharp.UI/src/router.js deleted file mode 100644 index d81402e4..00000000 --- a/BotSharp.UI/src/router.js +++ /dev/null @@ -1,17 +0,0 @@ -const routers = [ - { - path: '/', - meta: { - title: 'BotSharp' - }, - component: (resolve) => require(['./views/index.vue'], resolve) - }, - { - path: '/login', - meta: { - title: 'Login' - }, - component: (resolve) => require(['./views/index.vue'], resolve) - } -]; -export default routers; \ No newline at end of file diff --git a/BotSharp.UI/src/styles/common.css b/BotSharp.UI/src/styles/common.css deleted file mode 100644 index 5604043a..00000000 --- a/BotSharp.UI/src/styles/common.css +++ /dev/null @@ -1,3 +0,0 @@ -body, html { - height: 100%; -} \ No newline at end of file diff --git a/BotSharp.UI/src/template/index.ejs b/BotSharp.UI/src/template/index.ejs deleted file mode 100644 index 0499fc57..00000000 --- a/BotSharp.UI/src/template/index.ejs +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - -
- - - - \ No newline at end of file diff --git a/BotSharp.UI/src/vendors.js b/BotSharp.UI/src/vendors.js deleted file mode 100644 index 8e16d96f..00000000 --- a/BotSharp.UI/src/vendors.js +++ /dev/null @@ -1,3 +0,0 @@ -import Vue from 'vue'; -import iView from 'iview'; -import VueRouter from 'vue-router'; \ No newline at end of file diff --git a/BotSharp.UI/src/views/account/login.vue b/BotSharp.UI/src/views/account/login.vue deleted file mode 100644 index d1c651c8..00000000 --- a/BotSharp.UI/src/views/account/login.vue +++ /dev/null @@ -1,66 +0,0 @@ - - - - - diff --git a/BotSharp.UI/src/views/account/settings.vue b/BotSharp.UI/src/views/account/settings.vue deleted file mode 100644 index 3cc737ef..00000000 --- a/BotSharp.UI/src/views/account/settings.vue +++ /dev/null @@ -1,69 +0,0 @@ - - \ No newline at end of file diff --git a/BotSharp.UI/src/views/account/user-status.vue b/BotSharp.UI/src/views/account/user-status.vue deleted file mode 100644 index 3b573742..00000000 --- a/BotSharp.UI/src/views/account/user-status.vue +++ /dev/null @@ -1,43 +0,0 @@ - - - - \ No newline at end of file diff --git a/BotSharp.UI/src/views/dashboard.vue b/BotSharp.UI/src/views/dashboard.vue deleted file mode 100644 index f74d9e4a..00000000 --- a/BotSharp.UI/src/views/dashboard.vue +++ /dev/null @@ -1,31 +0,0 @@ - - diff --git a/BotSharp.UI/src/views/index.vue b/BotSharp.UI/src/views/index.vue deleted file mode 100644 index e9e9cb84..00000000 --- a/BotSharp.UI/src/views/index.vue +++ /dev/null @@ -1,84 +0,0 @@ - - - - - \ No newline at end of file diff --git a/BotSharp.UI/src/views/master.vue b/BotSharp.UI/src/views/master.vue deleted file mode 100644 index 036c0c2b..00000000 --- a/BotSharp.UI/src/views/master.vue +++ /dev/null @@ -1,190 +0,0 @@ - - - - - \ No newline at end of file diff --git a/BotSharp.UI/webpack.base.config.js b/BotSharp.UI/webpack.base.config.js deleted file mode 100644 index ee9cb816..00000000 --- a/BotSharp.UI/webpack.base.config.js +++ /dev/null @@ -1,70 +0,0 @@ -const path = require('path'); -const webpack = require('webpack'); -const ExtractTextPlugin = require('extract-text-webpack-plugin'); - -module.exports = { - entry: { - main: './src/main', - vendors: './src/vendors' - }, - output: { - path: path.join(__dirname, './dist') - }, - module: { - rules: [ - { - test: /\.vue$/, - loader: 'vue-loader', - options: { - loaders: { - less: ExtractTextPlugin.extract({ - use: ['css-loader?minimize', 'autoprefixer-loader', 'less-loader'], - fallback: 'vue-style-loader' - }), - css: ExtractTextPlugin.extract({ - use: ['css-loader', 'autoprefixer-loader', 'less-loader'], - fallback: 'vue-style-loader' - }) - } - } - }, - { - test: /iview\/.*?js$/, - loader: 'babel-loader' - }, - { - test: /\.js$/, - loader: 'babel-loader', - exclude: /node_modules/ - }, - { - test: /\.css$/, - use: ExtractTextPlugin.extract({ - use: ['css-loader?minimize', 'autoprefixer-loader'], - fallback: 'style-loader' - }) - }, - { - test: /\.less/, - use: ExtractTextPlugin.extract({ - use: ['css-loader?minimize', 'autoprefixer-loader', 'less-loader'], - fallback: 'style-loader' - }) - }, - { - test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, - loader: 'url-loader?limit=1024' - }, - { - test: /\.(html|tpl)$/, - loader: 'html-loader' - } - ] - }, - resolve: { - extensions: ['.js', '.vue'], - alias: { - 'vue': 'vue/dist/vue.esm.js' - } - } -}; \ No newline at end of file diff --git a/BotSharp.UI/webpack.dev.config.js b/BotSharp.UI/webpack.dev.config.js deleted file mode 100644 index ad884312..00000000 --- a/BotSharp.UI/webpack.dev.config.js +++ /dev/null @@ -1,39 +0,0 @@ -const webpack = require('webpack'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const ExtractTextPlugin = require('extract-text-webpack-plugin'); -const merge = require('webpack-merge'); -const webpackBaseConfig = require('./webpack.base.config.js'); -const fs = require('fs'); - -fs.open('./src/config/env.js', 'w', function (err, fd) { - const buf = 'export default "development";'; - fs.write(fd, buf, 0, buf.length, 0, function (err, written, buffer){}); -}); - -module.exports = merge(webpackBaseConfig, { - devtool: '#source-map', - output: { - publicPath: '/dist/', - filename: '[name].js', - chunkFilename: '[name].chunk.js' - }, - devServer: { - inline:true, - port: 3110 - }, - plugins: [ - new ExtractTextPlugin({ - filename: '[name].css', - allChunks: true - }), - new webpack.optimize.CommonsChunkPlugin({ - name: 'vendors', - filename: 'vendors.js' - }), - new HtmlWebpackPlugin({ - filename: '../index.html', - template: './src/template/index.ejs', - inject: false - }) - ] -}); \ No newline at end of file diff --git a/BotSharp.UI/webpack.prod.config.js b/BotSharp.UI/webpack.prod.config.js deleted file mode 100644 index d698abc6..00000000 --- a/BotSharp.UI/webpack.prod.config.js +++ /dev/null @@ -1,44 +0,0 @@ -const webpack = require('webpack'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const ExtractTextPlugin = require('extract-text-webpack-plugin'); -const merge = require('webpack-merge'); -const webpackBaseConfig = require('./webpack.base.config.js'); -const fs = require('fs'); - -fs.open('./src/config/env.js', 'w', function (err, fd) { - const buf = 'export default "production";'; - fs.write(fd, buf, 0, buf.length, 0, function (err, written, buffer){}); -}); - -module.exports = merge(webpackBaseConfig, { - output: { - publicPath: '/dist/', - filename: '[name].[hash].js', - chunkFilename: '[name].[hash].chunk.js' - }, - plugins: [ - new ExtractTextPlugin({ - filename: '[name].[hash].css', - allChunks: true - }), - new webpack.optimize.CommonsChunkPlugin({ - name: 'vendors', - filename: 'vendors.[hash].js' - }), - new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: '"production"' - } - }), - new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false - } - }), - new HtmlWebpackPlugin({ - filename: '../index_prod.html', - template: './src/template/index.ejs', - inject: false - }) - ] -}); \ No newline at end of file diff --git a/BotSharp.UI/webpack.pub.config.js b/BotSharp.UI/webpack.pub.config.js deleted file mode 100644 index c2365ed4..00000000 --- a/BotSharp.UI/webpack.pub.config.js +++ /dev/null @@ -1,91 +0,0 @@ -var webpack = require("webpack"); -var path = require('path'); -var uglifyJsPlugin = webpack.optimize.UglifyJsPlugin; -var ExtractTextPlugin = require("extract-text-webpack-plugin"); -var HtmlWebpackPlugin = require('html-webpack-plugin'); - -var ROOT_PATH = path.resolve(__dirname); // 项目跟路径 -var APP_PATH = path.resolve(ROOT_PATH, 'Views'); // 项目开发目录src -var APP_FILE = path.resolve(APP_PATH, 'index.js'); // 项目入口的index.js -var DIST_PATH = path.resolve(ROOT_PATH, 'dist'); // 项目打包输出路径 - -module.exports = { - entry: { - app: APP_FILE, - venders: [ - 'react', - 'react-dom', - 'react-router', - // 'antd',这里直接会把所有antd打包 - 'mockjs', - 'babel-polyfill' - ] - }, - output: { - path: DIST_PATH, - filename: '[name].js', - chunkFilename: 'js/[name].[chunkhash:5].min.js' - }, - module: { - loaders: [ - { - test: /\.css$/, - loader: ExtractTextPlugin.extract('style', ['css', 'autoprefixer']) - }, - { - test: /\.less$/, - loader: ExtractTextPlugin.extract('style', ['css', 'autoprefixer', 'less']) - }, - { - test: /\.jsx?$/, - exclude: /node_modules/, - loaders: ['react-hot', 'babel?presets[]=es2015,presets[]=react,presets[]=stage-0'] - }, - { - test: /\.(png|jpg)$/, - loader: 'file-loader?limit=8192&name=images/[hash:8].[name].[ext]' - }, - { - test: /\.(woff|woff2|eot|ttf|svg)(\?.*$|$)/, - loader: 'url' - } - ] - }, - resolve: { - extensions: ['', '.js', '.jsx', '.json', '.less'] - }, - plugins: [ - // new webpack.ProvidePlugin({ $: "jquery" }), // 这是将jquery变成全局变量,不用在自己文件require('jquery')了 - new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: JSON.stringify('production') //定义生产环境 - } - }), - new webpack.optimize.CommonsChunkPlugin('venders', 'venders.js'), // 这是第三方库打包生成的文件 - new uglifyJsPlugin({ - output: { - comments: false, // remove all comments - }, - compress: { - warnings: false - } - }), - new ExtractTextPlugin("[name].css"), - new HtmlWebpackPlugin({ - template: './Views/template/template.html', // html模板路径 - htmlWebpackPlugin: { - files: { - css: ["app.css"], - js: ["bundle.js", "venders.js"] - } - }, - minify: { - removeComments: true, - collapseWhitespace: true, // 删除空白符与换行符 - removeAttributeQuotes: true // 移除HTML中的属性引号 - }, - filename: 'index.html', - favicon:'./Views/favicon.ico', //favicon路径 - }) - ] -};