分类目录归档:前端开发

vscode 配置文件

vs code 开发常用配置文件

{
    "editor.fontFamily": "Ubuntu Mono",
    "editor.fontSize": 16,
    "editor.lineHeight": 30,
    "explorer.confirmDelete": false,
    // Default formatter for <template> region
    "git.enableSmartCommit": true,
    "editor.quickSuggestions": {
        "strings": true
    },
    "git.autofetch": true,
    "workbench.colorTheme": "One Dark Pro",
    "element-helper.version": "2.4",
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "explorer.confirmDragAndDrop": false,
    // vscode默认启用了根据文件类型自动设置tabsize的选项
    "editor.detectIndentation": false,
    "files.autoSave": "off",
    // 添加 vue 支持
    // "eslint.run": "onSave",
    //  #去掉代码结尾的分号
    "prettier.semi": false,
    //  #使用带引号替代双引号
    "prettier.singleQuote": true,
    // // #这个按用户自身习惯选择
    "vetur.format.defaultFormatter.html": "js-beautify-html",
    // //  #让函数(名)和后面的括号之间加个空格
    "javascript.format.insertSpaceBeforeFunctionParenthesis": false,
    "typescript.format.insertSpaceBeforeFunctionParenthesis": false,
    "vetur.format.defaultFormatterOptions": {
        "js-beautify-html": {
            "wrap_attributes": "force-aligned"
            // #vue组件中html代码格式化样式
        }
    },
    "[javascript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "window.zoomLevel": 0,
    "terminal.integrated.fontSize": 16,
    "[vue]": {
        "editor.defaultFormatter": "octref.vetur"
    },
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": false
    },
    "[json]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[html]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "files.exclude": {
        "**/.classpath": true,
        "**/.project": true,
        "**/.settings": true,
        "**/.factorypath": true
    },
    "workbench.sideBar.location": "left",
    "editor.formatOnSave": true,
    "vetur.format.defaultFormatter.js": "vscode-typescript",
    "eslint.codeActionsOnSave.mode": "problems",
    // "eslint.enable": false,
    "eslint.format.enable": true,
    "workbench.iconTheme": "material-icon-theme",
    "[jsonc]": {
        "editor.defaultFormatter": "vscode.json-language-features"
    },
    "editor.renameOnType": true,
    "vsicons.dontShowNewVersionMessage": true,
    "workbench.statusBar.visible": false,
    "workbench.activityBar.visible": true
}

webpack 加密压缩 js文件

UglifyJS Webpack Plugin插件用来缩小(压缩优化)js文件

单个文件压缩

# 命令:webpack [js文件]
# 例如打包app.js
webpack app.js

如果是多个文件就采用webpack.config.js文件来配置。

基础配置 webpack.config.js文件

const path = require("path");
const UglifyJsPlugin = require('uglifyjs-3-webpack-plugin');
module.exports = {
    mode: "production",
    entry: {
        common: path.resolve(__dirname, './template/src/common.js') // 入口文件
    },
    output: {
        path: path.resolve(__dirname, './dist/'), // 打包目录
        filename: '[name].min.js', // 输出文件名
        chunkFilename: '[name].min.js' // commonChunk 输出文件
    },
    optimization: {
        minimizer: [new UglifyJsPlugin()]
    }
}

Visual Studio Code Vue.js 开发环境配置

插件安装

以下是必须安装的插件

  • Vetur 语法支持
  • ESLint 语法检查
  • Prettier 代码格式化

代码格式化配置

{
    "editor.fontSize": 16,
    "editor.fontFamily": "Source Code Pro",
    "editor.lineHeight": 36,
    "explorer.confirmDelete": false,
    // Default formatter for <template> region
    "git.enableSmartCommit": true,
    "editor.quickSuggestions": {
        "strings": true
    },
    "git.autofetch": true,
    "workbench.colorTheme": "One Dark Pro",
    "element-helper.version": "2.4",
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "explorer.confirmDragAndDrop": false,
    // vscode默认启用了根据文件类型自动设置tabsize的选项
    "editor.detectIndentation": false,
    "files.autoSave": "off",
    // 添加 vue 支持
    // "eslint.run": "onSave",
    //  #去掉代码结尾的分号
    "prettier.semi": false,
    //  #使用带引号替代双引号
    "prettier.singleQuote": true,
    // // #这个按用户自身习惯选择
    "vetur.format.defaultFormatter.html": "js-beautify-html",
    // //  #让函数(名)和后面的括号之间加个空格
    "javascript.format.insertSpaceBeforeFunctionParenthesis": false,
    "typescript.format.insertSpaceBeforeFunctionParenthesis": false,
    "vetur.format.defaultFormatterOptions": {
        "js-beautify-html": {
            "wrap_attributes": "force-aligned"
            // #vue组件中html代码格式化样式
        }
    },
    "[javascript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "window.zoomLevel": 0,
    "terminal.integrated.fontSize": 16,
    "[vue]": {
        "editor.defaultFormatter": "octref.vetur"
    },
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": false
    },
    "[json]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[html]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "files.exclude": {
        "**/.classpath": true,
        "**/.project": true,
        "**/.settings": true,
        "**/.factorypath": true
    },
    "workbench.sideBar.location": "left",
    "editor.formatOnSave": true,
    "vetur.format.defaultFormatter.js": "vscode-typescript",
    "eslint.codeActionsOnSave.mode": "problems",
    "eslint.enable": false,
    "eslint.format.enable": true,
    "workbench.iconTheme": "material-icon-theme"
}