├── .babelrc ├── .editorconfig ├── .gitignore ├── .postcssrc.js ├── README.md ├── build ├── build.js ├── check-versions.js ├── logo.png ├── utils.js ├── vue-loader.conf.js ├── webpack.base.conf.js ├── webpack.dev.conf.js └── webpack.prod.conf.js ├── config ├── dev.env.js ├── index.js └── prod.env.js ├── dist ├── index.html ├── index2.html └── static │ ├── c426a1116301d1fd178c51522484127a.png │ ├── css │ ├── app.8b22e2d5120f6b4c1fb7d92153b8b2e1.css │ ├── app.8b22e2d5120f6b4c1fb7d92153b8b2e1.css.map │ ├── app2.f43349acabbb5cfa7a522590e4a49437.css │ └── app2.f43349acabbb5cfa7a522590e4a49437.css.map │ ├── default.min.css │ ├── favicon.png │ ├── fluidicon.png │ ├── highlight.min.js │ ├── img │ └── fontawesome-webfont.912ec66.svg │ ├── js │ ├── 0.f691fc72e4331bcef110.js │ ├── 0.f691fc72e4331bcef110.js.map │ ├── app.391f097eda82ab9280b2.js │ ├── app.391f097eda82ab9280b2.js.map │ ├── app2.4e10e40b7bbf2eced221.js │ ├── app2.4e10e40b7bbf2eced221.js.map │ ├── manifest.ea9d48c2a374a483b11a.js │ ├── manifest.ea9d48c2a374a483b11a.js.map │ ├── vendor.af88bba1948784debf9c.js │ └── vendor.af88bba1948784debf9c.js.map │ └── simulator.js ├── favicon.ico ├── index.html ├── index2.html ├── package-lock.json ├── package.json ├── src ├── App.vue ├── index.md ├── main.js ├── manoeuvre.js ├── manoeuvre.vue ├── router │ ├── config.js │ ├── dome.js │ └── index.js ├── views │ ├── Button.vue │ ├── Cache.vue │ ├── Cell.vue │ ├── FormHttp.vue │ ├── Icon.vue │ ├── List.vue │ ├── Loadings.vue │ ├── NavBar.vue │ ├── Picture.vue │ ├── Popup.vue │ ├── Regular.vue │ ├── Sticky.vue │ ├── Swipe.vue │ ├── Switch.vue │ ├── Toast.vue │ ├── brief.vue │ ├── index.vue │ ├── mlAlert.vue │ └── mlLazy.vue └── vue-tool │ ├── package.json │ ├── packages │ ├── Button │ │ └── src │ │ │ └── index.md │ ├── Cache │ │ ├── index.js │ │ └── src │ │ │ ├── index.js │ │ │ └── index.md │ ├── Cell │ │ └── src │ │ │ └── index.md │ ├── FormHttp │ │ ├── index.js │ │ └── src │ │ │ ├── index.js │ │ │ └── index.md │ ├── Icon │ │ ├── index.js │ │ └── src │ │ │ ├── index.md │ │ │ └── index.vue │ ├── InfiniteScroll │ │ ├── index.js │ │ └── src │ │ │ ├── index.js │ │ │ ├── index.md │ │ │ └── scroll.js │ ├── Loadings │ │ ├── index.js │ │ └── src │ │ │ ├── index.js │ │ │ ├── index.md │ │ │ └── index.vue │ ├── NavBar │ │ ├── index.js │ │ └── src │ │ │ ├── index.md │ │ │ └── index.vue │ ├── Picture │ │ ├── index.js │ │ └── src │ │ │ ├── index.js │ │ │ └── index.md │ ├── Popup │ │ ├── index.js │ │ └── src │ │ │ ├── index.md │ │ │ └── index.vue │ ├── Regular │ │ ├── index.js │ │ └── src │ │ │ ├── index.js │ │ │ └── index.md │ ├── Sticky │ │ ├── index.js │ │ └── src │ │ │ ├── index.md │ │ │ └── index.vue │ ├── Swipe │ │ └── src │ │ │ └── index.md │ ├── Switch │ │ ├── index.js │ │ └── src │ │ │ ├── index.md │ │ │ └── index.vue │ ├── Toast │ │ └── src │ │ │ ├── index.md │ │ │ └── start.vue │ ├── button │ │ ├── index.js │ │ └── src │ │ │ └── index.vue │ ├── cell │ │ ├── index.js │ │ └── src │ │ │ └── index.vue │ ├── imgEnlarge │ │ ├── index.js │ │ └── src │ │ │ └── index.md │ ├── mlAlert │ │ ├── index.js │ │ └── src │ │ │ ├── index.js │ │ │ ├── index.md │ │ │ └── index.vue │ ├── mlLazy │ │ ├── index.js │ │ └── src │ │ │ ├── index.js │ │ │ └── index.md │ ├── picker │ │ ├── index.js │ │ └── src │ │ │ └── index.md │ ├── swipe │ │ ├── index.js │ │ └── src │ │ │ ├── index.js │ │ │ ├── index.vue │ │ │ └── swipeItem.vue │ ├── tab │ │ ├── index.js │ │ └── src │ │ │ ├── index.js │ │ │ ├── index.md │ │ │ └── index.vue │ └── toast │ │ ├── index.js │ │ └── src │ │ ├── index.js │ │ └── index.vue │ └── src │ ├── index.js │ └── unity │ └── index.js └── static ├── .gitkeep ├── c426a1116301d1fd178c51522484127a.png ├── default.min.css ├── favicon.png ├── fluidicon.png ├── highlight.min.js └── simulator.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] 7 | } 8 | }], 9 | "stage-2" 10 | ], 11 | "plugins": ["transform-vue-jsx", "transform-runtime"] 12 | } 13 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | npm-debug.log* 4 | yarn-debug.log* 5 | yarn-error.log* 6 | 7 | # Editor directories and files 8 | .idea 9 | .vscode 10 | *.suo 11 | *.ntvs* 12 | *.njsproj 13 | *.sln 14 | -------------------------------------------------------------------------------- /.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 9 |
12 |13 | 14 | 一套收集各式各样、偶尔维护的UI库, mintUi,Vant的设计 15 | 16 |
17 |18 | 19 | 为什么现在又那么多开源的UI框架,我为什么又要在写一套!下面我来解释一下 20 | 21 |
22 | 23 | > 对自己能力的提升! 24 | 25 | > 想拥有一个自己的UI框架,现在的UI框架太散落,总是找来找去的! 26 | 27 | > 想了解一下webpack以及各种loader的打包机制! 28 | 29 | > 就是想装B一下! 嗯嗯 就这个 30 | 31 | **NPM同步安装 vue-tool:[超快传送!点击查看演示效果](https://1292150917.github.io/vueToolOfficial/dist/index.html#/brief) 32 | 33 | 可以用在vue其他项目中 安装命令 34 | 35 | ``` bash 36 | 37 | npm install vue-tool 38 | 39 | 在main.js中 40 | 41 | import vueTool from vueTool 42 | 43 | vue.use(vueTool) 44 | 45 | ``` 46 | 47 | ## Build Setup 48 | 49 | ``` bash 50 | # install dependencies 51 | npm install 52 | 53 | # serve with hot reload at localhost:8080 54 | npm run dev 55 | 56 | # build for production with minification 57 | npm run build 58 | 59 | # build for production and view the bundle analyzer report 60 | npm run build --report 61 | ``` 62 | -------------------------------------------------------------------------------- /build/build.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | require('./check-versions')() 3 | 4 | process.env.NODE_ENV = 'production' 5 | 6 | const ora = require('ora') 7 | const rm = require('rimraf') 8 | const path = require('path') 9 | const chalk = require('chalk') 10 | const webpack = require('webpack') 11 | const config = require('../config') 12 | const webpackConfig = require('./webpack.prod.conf') 13 | 14 | const spinner = ora('building for production...') 15 | spinner.start() 16 | 17 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { 18 | if (err) throw err 19 | webpack(webpackConfig, (err, stats) => { 20 | spinner.stop() 21 | if (err) throw err 22 | process.stdout.write(stats.toString({ 23 | colors: true, 24 | modules: false, 25 | children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build. 26 | chunks: false, 27 | chunkModules: false 28 | }) + '\n\n') 29 | 30 | if (stats.hasErrors()) { 31 | console.log(chalk.red(' Build failed with errors.\n')) 32 | process.exit(1) 33 | } 34 | 35 | console.log(chalk.cyan(' Build complete.\n')) 36 | console.log(chalk.yellow( 37 | ' Tip: built files are meant to be served over an HTTP server.\n' + 38 | ' Opening index.html over file:// won\'t work.\n' 39 | )) 40 | }) 41 | }) 42 | -------------------------------------------------------------------------------- /build/check-versions.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const chalk = require('chalk') 3 | const semver = require('semver') 4 | const packageConfig = require('../package.json') 5 | const shell = require('shelljs') 6 | 7 | function exec (cmd) { 8 | return require('child_process').execSync(cmd).toString().trim() 9 | } 10 | 11 | const versionRequirements = [ 12 | { 13 | name: 'node', 14 | currentVersion: semver.clean(process.version), 15 | versionRequirement: packageConfig.engines.node 16 | } 17 | ] 18 | 19 | if (shell.which('npm')) { 20 | versionRequirements.push({ 21 | name: 'npm', 22 | currentVersion: exec('npm --version'), 23 | versionRequirement: packageConfig.engines.npm 24 | }) 25 | } 26 | 27 | module.exports = function () { 28 | const warnings = [] 29 | 30 | for (let i = 0; i < versionRequirements.length; i++) { 31 | const mod = versionRequirements[i] 32 | 33 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 34 | warnings.push(mod.name + ': ' + 35 | chalk.red(mod.currentVersion) + ' should be ' + 36 | chalk.green(mod.versionRequirement) 37 | ) 38 | } 39 | } 40 | 41 | if (warnings.length) { 42 | console.log('') 43 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 44 | console.log() 45 | 46 | for (let i = 0; i < warnings.length; i++) { 47 | const warning = warnings[i] 48 | console.log(' ' + warning) 49 | } 50 | 51 | console.log() 52 | process.exit(1) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1292150917/vueToolOfficial/43ff215141e4b679c4a0774bd8bea348a9a4faef/build/logo.png -------------------------------------------------------------------------------- /build/utils.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const config = require('../config') 4 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 5 | const packageConfig = require('../package.json') 6 | 7 | exports.assetsPath = function (_path) { 8 | const assetsSubDirectory = process.env.NODE_ENV === 'production' 9 | ? config.build.assetsSubDirectory 10 | : config.dev.assetsSubDirectory 11 | 12 | return path.posix.join(assetsSubDirectory, _path) 13 | } 14 | 15 | exports.cssLoaders = function (options) { 16 | options = options || {} 17 | 18 | const cssLoader = { 19 | loader: 'css-loader', 20 | options: { 21 | sourceMap: options.sourceMap 22 | } 23 | } 24 | 25 | const postcssLoader = { 26 | loader: 'postcss-loader', 27 | options: { 28 | sourceMap: options.sourceMap 29 | } 30 | } 31 | 32 | // generate loader string to be used with extract text plugin 33 | function generateLoaders (loader, loaderOptions) { 34 | const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader] 35 | 36 | if (loader) { 37 | loaders.push({ 38 | loader: loader + '-loader', 39 | options: Object.assign({}, loaderOptions, { 40 | sourceMap: options.sourceMap 41 | }) 42 | }) 43 | } 44 | 45 | // Extract CSS when that option is specified 46 | // (which is the case during production build) 47 | if (options.extract) { 48 | return ExtractTextPlugin.extract({ 49 | use: loaders, 50 | fallback: 'vue-style-loader' 51 | }) 52 | } else { 53 | return ['vue-style-loader'].concat(loaders) 54 | } 55 | } 56 | 57 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html 58 | return { 59 | css: generateLoaders(), 60 | postcss: generateLoaders(), 61 | less: generateLoaders('less'), 62 | sass: generateLoaders('sass', { indentedSyntax: true }), 63 | scss: generateLoaders('sass'), 64 | stylus: generateLoaders('stylus'), 65 | styl: generateLoaders('stylus') 66 | } 67 | } 68 | 69 | // Generate loaders for standalone style files (outside of .vue) 70 | exports.styleLoaders = function (options) { 71 | const output = [] 72 | const loaders = exports.cssLoaders(options) 73 | 74 | for (const extension in loaders) { 75 | const loader = loaders[extension] 76 | output.push({ 77 | test: new RegExp('\\.' + extension + '$'), 78 | use: loader 79 | }) 80 | } 81 | 82 | return output 83 | } 84 | 85 | exports.createNotifierCallback = () => { 86 | const notifier = require('node-notifier') 87 | 88 | return (severity, errors) => { 89 | if (severity !== 'error') return 90 | 91 | const error = errors[0] 92 | const filename = error.file && error.file.split('!').pop() 93 | 94 | notifier.notify({ 95 | title: packageConfig.name, 96 | message: severity + ': ' + error.name, 97 | subtitle: filename || '', 98 | icon: path.join(__dirname, 'logo.png') 99 | }) 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const config = require('../config') 4 | const isProduction = process.env.NODE_ENV === 'production' 5 | const sourceMapEnabled = isProduction 6 | ? config.build.productionSourceMap 7 | : config.dev.cssSourceMap 8 | 9 | module.exports = { 10 | loaders: utils.cssLoaders({ 11 | sourceMap: sourceMapEnabled, 12 | extract: isProduction 13 | }), 14 | cssSourceMap: sourceMapEnabled, 15 | cacheBusting: config.dev.cacheBusting, 16 | transformToRequire: { 17 | video: ['src', 'poster'], 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const utils = require('./utils') 4 | const config = require('../config') 5 | const vueLoaderConfig = require('./vue-loader.conf') 6 | const hljs = require('highlight.js') 7 | 8 | function resolve(dir) { 9 | return path.join(__dirname, '..', dir) 10 | } 11 | 12 | 13 | 14 | module.exports = { 15 | context: path.resolve(__dirname, '../'), 16 | entry: { 17 | app: './src/main.js', 18 | app2: './src/manoeuvre.js' 19 | }, 20 | output: { 21 | path: config.build.assetsRoot, 22 | filename: '[name].js', 23 | publicPath: process.env.NODE_ENV === 'production' ? 24 | config.build.assetsPublicPath : config.dev.assetsPublicPath 25 | }, 26 | resolve: { 27 | extensions: ['.js', '.vue', '.json'], 28 | alias: { 29 | 'vue$': 'vue/dist/vue.esm.js', 30 | '@': resolve('src'), 31 | } 32 | }, 33 | module: { 34 | rules: [{ 35 | test: /\.vue$/, 36 | loader: 'vue-loader', 37 | options: vueLoaderConfig 38 | }, 39 | { 40 | test: /\.js$/, 41 | loader: 'babel-loader', 42 | include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')] 43 | }, 44 | { 45 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 46 | loader: 'url-loader', 47 | options: { 48 | limit: 10000, 49 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 50 | } 51 | }, { 52 | test: /\.md$/, 53 | loader: 'vue-markdown-loader', 54 | options: { 55 | languages: [], 56 | preClass: 'hljs', // 代码高亮所必须的类名 57 | markdownItOptions: { 58 | highlight(str, lang) { 59 | if (lang && hljs.getLanguage(lang)) { 60 | try { 61 | return hljs.highlight(lang, str).value 62 | } catch (__) {} 63 | } 64 | 65 | return '' 66 | } 67 | } 68 | } 69 | }, 70 | { 71 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 72 | loader: 'url-loader', 73 | options: { 74 | limit: 10000, 75 | name: utils.assetsPath('media/[name].[hash:7].[ext]') 76 | } 77 | }, 78 | { 79 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 80 | loader: 'url-loader' 81 | // options: { 82 | // limit: 10000, 83 | // name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 84 | // } 85 | } 86 | ] 87 | }, 88 | node: { 89 | // prevent webpack from injecting useless setImmediate polyfill because Vue 90 | // source contains it (although only uses it if it's native). 91 | setImmediate: false, 92 | // prevent webpack from injecting mocks to Node native modules 93 | // that does not make sense for the client 94 | dgram: 'empty', 95 | fs: 'empty', 96 | net: 'empty', 97 | tls: 'empty', 98 | child_process: 'empty' 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const webpack = require('webpack') 4 | const config = require('../config') 5 | const merge = require('webpack-merge') 6 | const path = require('path') 7 | const baseWebpackConfig = require('./webpack.base.conf') 8 | const CopyWebpackPlugin = require('copy-webpack-plugin') 9 | const HtmlWebpackPlugin = require('html-webpack-plugin') 10 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 11 | const portfinder = require('portfinder') 12 | 13 | const HOST = process.env.HOST 14 | const PORT = process.env.PORT && Number(process.env.PORT) 15 | 16 | const devWebpackConfig = merge(baseWebpackConfig, { 17 | module: { 18 | rules: utils.styleLoaders({ 19 | sourceMap: config.dev.cssSourceMap, 20 | usePostCSS: true 21 | }) 22 | }, 23 | // cheap-module-eval-source-map is faster for development 24 | devtool: config.dev.devtool, 25 | 26 | // these devServer options should be customized in /config/index.js 27 | devServer: { 28 | clientLogLevel: 'warning', 29 | historyApiFallback: { 30 | rewrites: [{ 31 | from: /.*/, 32 | to: path.posix.join(config.dev.assetsPublicPath, 'index.html') 33 | }, ], 34 | }, 35 | hot: true, 36 | contentBase: false, // since we use CopyWebpackPlugin. 37 | compress: true, 38 | host: HOST || config.dev.host, 39 | port: PORT || config.dev.port, 40 | open: config.dev.autoOpenBrowser, 41 | overlay: config.dev.errorOverlay ? 42 | { 43 | warnings: false, 44 | errors: true 45 | } : 46 | false, 47 | publicPath: config.dev.assetsPublicPath, 48 | proxy: config.dev.proxyTable, 49 | quiet: true, // necessary for FriendlyErrorsPlugin 50 | watchOptions: { 51 | poll: config.dev.poll, 52 | } 53 | }, 54 | plugins: [ 55 | new webpack.DefinePlugin({ 56 | 'process.env': require('../config/dev.env') 57 | }), 58 | new webpack.HotModuleReplacementPlugin(), 59 | new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update. 60 | new webpack.NoEmitOnErrorsPlugin(), 61 | // https://github.com/ampedandwired/html-webpack-plugin 62 | new HtmlWebpackPlugin({ 63 | filename: 'index.html', 64 | template: 'index.html', 65 | inject: true, 66 | chunks: ['app'] //需要引入的Chunk,不配置就会引入所有页面的资源 67 | }), 68 | new HtmlWebpackPlugin({ 69 | filename: 'index2.html', 70 | template: 'index2.html', 71 | inject: true, 72 | chunks: ['app2'] //需要引入的Chunk,不配置就会引入所有页面的资源 73 | }), 74 | // copy custom static assets 75 | new CopyWebpackPlugin([{ 76 | from: path.resolve(__dirname, '../static'), 77 | to: config.dev.assetsSubDirectory, 78 | ignore: ['.*'] 79 | }]) 80 | ] 81 | }) 82 | 83 | module.exports = new Promise((resolve, reject) => { 84 | portfinder.basePort = process.env.PORT || config.dev.port 85 | portfinder.getPort((err, port) => { 86 | if (err) { 87 | reject(err) 88 | } else { 89 | // publish the new Port, necessary for e2e tests 90 | process.env.PORT = port 91 | // add port to devServer config 92 | devWebpackConfig.devServer.port = port 93 | 94 | // Add FriendlyErrorsPlugin 95 | devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({ 96 | compilationSuccessInfo: { 97 | messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`], 98 | }, 99 | onErrors: config.dev.notifyOnErrors ? 100 | utils.createNotifierCallback() : 101 | undefined 102 | })) 103 | 104 | resolve(devWebpackConfig) 105 | } 106 | }) 107 | }) 108 | -------------------------------------------------------------------------------- /build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const utils = require('./utils') 4 | const webpack = require('webpack') 5 | const config = require('../config') 6 | const merge = require('webpack-merge') 7 | const baseWebpackConfig = require('./webpack.base.conf') 8 | const CopyWebpackPlugin = require('copy-webpack-plugin') 9 | const HtmlWebpackPlugin = require('html-webpack-plugin') 10 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 11 | const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') 12 | const UglifyJsPlugin = require('uglifyjs-webpack-plugin') 13 | 14 | const env = require('../config/prod.env') 15 | 16 | const webpackConfig = merge(baseWebpackConfig, { 17 | module: { 18 | rules: utils.styleLoaders({ 19 | sourceMap: config.build.productionSourceMap, 20 | extract: true, 21 | usePostCSS: true 22 | }) 23 | }, 24 | devtool: config.build.productionSourceMap ? config.build.devtool : false, 25 | output: { 26 | path: config.build.assetsRoot, 27 | filename: utils.assetsPath('js/[name].[chunkhash].js'), 28 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 29 | }, 30 | plugins: [ 31 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 32 | new webpack.DefinePlugin({ 33 | 'process.env': env 34 | }), 35 | new UglifyJsPlugin({ 36 | uglifyOptions: { 37 | compress: { 38 | warnings: false 39 | } 40 | }, 41 | sourceMap: config.build.productionSourceMap, 42 | parallel: true 43 | }), 44 | // extract css into its own file 45 | new ExtractTextPlugin({ 46 | filename: utils.assetsPath('css/[name].[contenthash].css'), 47 | // Setting the following option to `false` will not extract CSS from codesplit chunks. 48 | // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. 49 | // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, 50 | // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 51 | allChunks: true, 52 | }), 53 | // Compress extracted CSS. We are using this plugin so that possible 54 | // duplicated CSS from different components can be deduped. 55 | new OptimizeCSSPlugin({ 56 | cssProcessorOptions: config.build.productionSourceMap 57 | ? { safe: true, map: { inline: false } } 58 | : { safe: true } 59 | }), 60 | // generate dist index.html with correct asset hash for caching. 61 | // you can customize output by editing /index.html 62 | // see https://github.com/ampedandwired/html-webpack-plugin 63 | new HtmlWebpackPlugin({ 64 | filename: config.build.index, 65 | template: 'index.html', 66 | inject: true, 67 | excludeChunks: ['app2'], //需要引入的Chunk,不配置就会引入所有页面的资源 68 | minify: { 69 | removeComments: true, 70 | collapseWhitespace: true, 71 | removeAttributeQuotes: true 72 | // more options: 73 | // https://github.com/kangax/html-minifier#options-quick-reference 74 | }, 75 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 76 | chunksSortMode: 'dependency' 77 | }), 78 | new HtmlWebpackPlugin({ 79 | filename: config.build.index2, 80 | template: 'index2.html', 81 | inject: true, 82 | excludeChunks: ['app'], //需要引入的Chunk,不配置就会引入所有页面的资源 83 | minify: { 84 | removeComments: true, 85 | collapseWhitespace: true, 86 | removeAttributeQuotes: true 87 | // more options: 88 | // https://github.com/kangax/html-minifier#options-quick-reference 89 | }, 90 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 91 | chunksSortMode: 'dependency' 92 | }), 93 | // keep module.id stable when vendor modules does not change 94 | new webpack.HashedModuleIdsPlugin(), 95 | // enable scope hoisting 96 | new webpack.optimize.ModuleConcatenationPlugin(), 97 | // split vendor js into its own file 98 | new webpack.optimize.CommonsChunkPlugin({ 99 | name: 'vendor', 100 | minChunks (module) { 101 | // any required modules inside node_modules are extracted to vendor 102 | return ( 103 | module.resource && 104 | /\.js$/.test(module.resource) && 105 | module.resource.indexOf( 106 | path.join(__dirname, '../node_modules') 107 | ) === 0 108 | ) 109 | } 110 | }), 111 | // extract webpack runtime and module manifest to its own file in order to 112 | // prevent vendor hash from being updated whenever app bundle is updated 113 | new webpack.optimize.CommonsChunkPlugin({ 114 | name: 'manifest', 115 | minChunks: Infinity 116 | }), 117 | // This instance extracts shared chunks from code splitted chunks and bundles them 118 | // in a separate chunk, similar to the vendor chunk 119 | // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk 120 | new webpack.optimize.CommonsChunkPlugin({ 121 | name: 'app', 122 | async: 'vendor-async', 123 | children: true, 124 | minChunks: 3 125 | }), 126 | 127 | // copy custom static assets 128 | new CopyWebpackPlugin([ 129 | { 130 | from: path.resolve(__dirname, '../static'), 131 | to: config.build.assetsSubDirectory, 132 | ignore: ['.*'] 133 | } 134 | ]) 135 | ] 136 | }) 137 | 138 | if (config.build.productionGzip) { 139 | const CompressionWebpackPlugin = require('compression-webpack-plugin') 140 | 141 | webpackConfig.plugins.push( 142 | new CompressionWebpackPlugin({ 143 | asset: '[path].gz[query]', 144 | algorithm: 'gzip', 145 | test: new RegExp( 146 | '\\.(' + 147 | config.build.productionGzipExtensions.join('|') + 148 | ')$' 149 | ), 150 | threshold: 10240, 151 | minRatio: 0.8 152 | }) 153 | ) 154 | } 155 | 156 | if (config.build.bundleAnalyzerReport) { 157 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 158 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()) 159 | } 160 | 161 | module.exports = webpackConfig 162 | -------------------------------------------------------------------------------- /config/dev.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const prodEnv = require('./prod.env') 4 | 5 | module.exports = merge(prodEnv, { 6 | NODE_ENV: '"development"' 7 | }) 8 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | // Template version: 1.3.1 3 | // see http://vuejs-templates.github.io/webpack for documentation. 4 | 5 | const path = require('path') 6 | 7 | module.exports = { 8 | dev: { 9 | 10 | // Paths 11 | assetsSubDirectory: 'static', 12 | assetsPublicPath: '/', 13 | proxyTable: {}, 14 | 15 | // Various Dev Server settings 16 | host: '0.0.0.0', // can be overwritten by process.env.HOST 17 | port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined 18 | autoOpenBrowser: false, 19 | errorOverlay: true, 20 | notifyOnErrors: true, 21 | poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- 22 | 23 | 24 | /** 25 | * Source Maps 26 | */ 27 | 28 | // https://webpack.js.org/configuration/devtool/#development 29 | devtool: 'cheap-module-eval-source-map', 30 | 31 | // If you have problems debugging vue-files in devtools, 32 | // set this to false - it *may* help 33 | // https://vue-loader.vuejs.org/en/options.html#cachebusting 34 | cacheBusting: true, 35 | 36 | cssSourceMap: true 37 | }, 38 | 39 | build: { 40 | // Template for index.html 41 | index: path.resolve(__dirname, '../dist/index.html'), 42 | index2: path.resolve(__dirname, '../dist/index2.html'), 43 | 44 | // Paths 45 | assetsRoot: path.resolve(__dirname, '../dist'), 46 | assetsSubDirectory: 'static', 47 | assetsPublicPath: './', 48 | 49 | /** 50 | * Source Maps 51 | */ 52 | 53 | productionSourceMap: true, 54 | // https://webpack.js.org/configuration/devtool/#production 55 | devtool: '#source-map', 56 | 57 | // Gzip off by default as many popular static hosts such as 58 | // Surge or Netlify already gzip all static assets for you. 59 | // Before setting to `true`, make sure to: 60 | // npm install --save-dev compression-webpack-plugin 61 | productionGzip: false, 62 | productionGzipExtensions: ['js', 'css'], 63 | 64 | // Run the build command with an extra argument to 65 | // View the bundle analyzer report after build finishes: 66 | // `npm run build --report` 67 | // Set to `true` or `false` to always turn it on or off 68 | bundleAnalyzerReport: process.env.npm_config_report 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /dist/index.html: -------------------------------------------------------------------------------- 1 |6 | 7 | 一套收集各式各样、偶尔维护的UI库, mintUi,Vant的设计 8 | 9 |
10 |11 | 12 | 为什么现在又那么多开源的UI框架,我为什么又要在写一套!下面我来解释一下 13 | 14 |
15 | 16 | > 对自己能力的提升! 17 | 18 | > 想拥有一个自己的UI框架,现在的UI框架太散落,总是找来找去的! 19 | 20 | > 想了解一下webpack以及各种loader的打包机制! 21 | 22 | > 就是想装B一下! 嗯嗯 就这个 23 | 24 | ## 25 | 26 | ## 快速上手 27 | 28 | ### 脚手架 29 | 30 | 推荐使用 Vue 官方提供的脚手架 Vue Cli 3 创建项目 31 | 32 | ### 方法使用说明 33 | 34 | 此方法提供各种转换方法!也是个人项目中经常使用到的!希望对你有帮助! 35 | 36 | ### 安装 37 | 38 | #### NPM 39 | 40 | ```javascript 41 | npm i vue-tool 42 | ``` 43 | 44 | #### YARN 45 | 46 | ```javascript 47 | yarn add vue-tool 48 | ``` 49 | 50 | #### CDN 51 | 52 | 暂不提供第三方CDN引入 53 | 54 | ### 引入组件 55 | 56 | 57 | 方式一. 使用 `babel-plugin-import` (推荐,方法来自vant,但是引入方式是一致的!) 58 | 59 | `babel-plugin-import ` 是一款 babel 插件,它会在编译过程中将 import 的写法自动转换为按需引入的方式 60 | 61 | ```javascript 62 | # 安装 babel-plugin-import 插件 63 | npm i babel-plugin-import -D 64 | ``` 65 | ##### 66 | 67 | ```javascript 68 | // .babelrc 中配置 69 | // 注意:webpack 1 无需设置 libraryDirectory 70 | { 71 | "plugins": [ 72 | ["import", { 73 | "libraryName": "vue-tool", 74 | "libraryDirectory": "es", 75 | "style": true 76 | }] 77 | ] 78 | } 79 | 80 | // 对于使用 babel7 的用户,可以在 babel.config.js 中配置 81 | module.exports = { 82 | plugins: [ 83 | ['import', { 84 | libraryName: 'vue-tool', 85 | libraryDirectory: 'es', 86 | style: true 87 | }, 'vue-tool'] 88 | ] 89 | }; 90 | ``` 91 | 92 | 接着你可以在代码中直接引入 vue-tool 组件,插件会自动将代码转化为方式二中的按需引入形式 93 | 94 | ```javascript 95 | 96 | import { Button } from 'vue-tool'; 97 | 98 | ``` 99 | 100 | 方式二. 导入所有组件 101 | 102 | ```javascript 103 | 104 | import Vue from 'vue'; 105 | import vueTool from 'vue-tool'; 106 | 107 | Vue.use(vueTool); 108 | 109 | ``` 110 | 111 | ##### 112 | 113 | `注意:配置 babel-plugin-import 插件后将不允许导入所有组件` 114 | 115 | ### Rem 适配 116 | 117 | vue-tool 中的样式默认使用px作为单位,如果需要使用rem单位,推荐使用以下两个工具 118 | 119 | `postcss-pxtorem` 是一款 `postcss` 插件,用于将单位转化为 rem 120 | `px2rem` 把px转换rem 121 | 也可以装对应的loader -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | import Vue from 'vue' 4 | import App from './App' 5 | import router from './router' 6 | import Vuetool from './vue-tool/src/index' 7 | import 'font-awesome/css/font-awesome.css' 8 | Vue.use(Vuetool) 9 | Vue.config.productionTip = false 10 | new Vue({ 11 | el: '#app', 12 | router, 13 | components: { App }, 14 | template: '基础用法
4 |单元格大小
7 |自定义大小
5 |自定义颜色
9 |更多图标(颜色可自定义)
12 |查看更多可看( Font Awesome 4.7.0 )
17 |基础用法
4 |上拉☞底部自动加载
5 |circleXuan
5 |spinner
7 |reload
9 |pacman
11 |ripple
13 |spin
15 |rolling
17 |infinity
19 |gear
21 |dualRing
25 |cube
27 |blocks
29 |ball
31 |wedges
33 |disk
35 |doubleRing
37 |flickr
39 |radio
41 |ldsCircle
43 |lds-ellipsis
45 |lds-hourglass
47 |lds-heart
49 |lds-ring
51 |lds-ripple
53 |基础用法
4 | 5 |弹出位置
6 |上拉☞查看效果
4 |{{item}}
5 |{{item}}
9 |1
13 |{{item}}
14 |{{item}}
18 |基本用法
4 |禁止手势滑动
27 |自定义滑动时间
50 |基础用法
4 |文字提示
4 | 5 | 6 |加载提示
7 | 8 |成功/失败提示
9 | 10 | 11 |vueTool,简洁,便利!
5 |开发指南
22 |快速上手
23 |方法
24 |{{key}}
29 |消息提示
4 | 5 | 6 |自定义按钮内容
7 | 8 | 9 |当前选择:{{ value7 }}
64 | ``` 65 | 66 | #### 搭配 Cell 使用 67 | 68 | `Checkbox`提供了一个`toggle`方法用来切换选中状态,你可以搭配`Cell`组件一起使用 69 | 70 | ```html 71 |当前选择:{{ value7 }}
70 | ``` 71 | 72 | #### 搭配 Cell 使用 73 | 74 | `Checkbox`提供了一个`toggle`方法用来切换选中状态,你可以搭配`Cell`组件一起使用 75 | 76 | ```html 77 |当前选择:{{ value7 }}
70 | ``` 71 | 72 | #### 搭配 Cell 使用 73 | 74 | `Checkbox`提供了一个`toggle`方法用来切换选中状态,你可以搭配`Cell`组件一起使用 75 | 76 | ```html 77 |当前选择:{{ value7 }}
70 | ``` 71 | 72 | #### 搭配 Cell 使用 73 | 74 | `Checkbox`提供了一个`toggle`方法用来切换选中状态,你可以搭配`Cell`组件一起使用 75 | 76 | ```html 77 |