npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vue2do/build

v1.1.15

Published

Tool for build Vue application

Downloads

7

Readme

Overview

npm version

Configuration

项目配置文件

在 cli 中一定需要传 path 参数的

Param webpack is webpack chain, Webpack Chain Github

apiUrl: '//example.com', // api 的地址
baseUrl: './', // 项目的根路径,默认是 __dirname
bundleAnalyzer: true, // 打包文件的分析
execute: './index.js', // 执行文件路径
favicon: './public/icon-coin.png', // favicon 路径
gzip: true, // 开启 gzip
port: 3000, // 热开发端口
htmlName: 'index', // html 的名字
htmlTitle: 'ex', // html 标题
name: 'example', // 项目名字,打包的文件名
outDir: './dist', // 输出的项目路径
proxy: {
  '/api/**': {
    target: 'https://www.api.com',
    secure: false,
    changeOrigin: true
  }
},
staticDir: 'static', // 静态文件打包路径
tpl: true, // 使用项目自带的 html 模板,默认为 false
type: 'spa', // 项目类型 spa | map
httpsOpt: true | { httpcert: './example.com.cert' }, // webpack 的 https 的配置
webpack(config) {
  // webpack chain config
  // see https://github.com/neutrinojs/webpack-chain for config.
  // 需要返回 config
  return config
}

ProjectConfig 参数

require 引入时可以只传入 config 参数,则必须传入 path。 如果也传入 configPath 了,会和 config 合并,且 config 的优先级更高


const vue2doBuild = require('@vue2do/build')

vue2doBuild.dev({
  config: {
    httpsOpt: false
  },
  configPath: path.resolve(__dirname, '../project.config.js')
})

vue2doBuild.prod({
  config: {
    httpsOpt: false,
    path: __dirname
  }
})

Webpack Chain

Loader 的基础配置

'jsx|tsx|pre': {
  ...commonRule,
  test: /\.(j|t)sx?$/,
  enforce: 'pre',
  use: {
    eslint: {
      loader: 'eslint-loader'
    }
  }
},
'ts|tsx': {
  ...commonRule,
  test: /\.tsx?$/,
  use: {
    babel: babelLoader,
    ts: {
      loader: 'ts-loader',
      options: {
        transpileOnly: true,
        experimentalWatchApi: true,
        compilerOptions: {
          module: 'es6',
          noEmit: true
        }
      }
    }
  }
},
'js|jsx': {
  ...commonRule,
  test: /\.jsx?$/,
  use: {
    babel: babelLoader
  }
},
css: {
  ...commonRule,
  include: [
    ...commonRule.include
  ],
  test: /\.(css)$/,
  use: {
    style: {
      loader: extractScss ? MiniCssExtractPlugin.loader : 'style-loader'
    },
    css: {
      loader: 'css-loader'
    },
    postcss: {
      loader: 'postcss-loader'
    }
  }
},
scss: {
  ...commonRule,
  test: /\.(scss)$/,
  use: {
    style: {
      loader: extractScss ? MiniCssExtractPlugin.loader : 'style-loader'
    },
    css: {
      loader: 'css-loader'
    },
    postcss: {
      loader: 'postcss-loader'
    },
    sass: {
      loader: 'sass-loader'
    }
  }
},
less: {
  ...commonRule,
  test: /\.(less)$/,
  use: {
    style: {
      loader: extractScss ? MiniCssExtractPlugin.loader : 'style-loader'
    },
    css: {
      loader: 'css-loader'
    },
    postcss: {
      loader: 'postcss-loader'
    },
    sass: {
      loader: 'less-loader'
    }
  }
},
img: {
  ...commonRule,
  test: /\.(png|jpe?g|gif|svg|woff2?|eot|ttf|otf)(\?.*)?$/,
  use: {
    url: {
      loader: 'url-loader',
      options: {
        limit: 10000,
        name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
      }
    }
  }
},
media: {
  ...commonRule,
  test: /\.(mp3|aac|ogg)(\?.*)?$/,
  use: {
    file: {
      loader: 'file-loader'
    }
  }
},
'html|tpl': {
  ...commonRule,
  test: /\.(html|tpl)$/,
  use: {
    file: {
      loader: 'html-loader'
    }
  }
}

Plugin 的基础配置

// base
...
plugin: {
  forkTsChecker: {
    plugin: ForkTsCheckerWebpackPlugin,
    args: [{
      eslint: true,
      async: true,
      watch: [projectPath],
      reportFiles: [projectPath]
    }]
  }
},
...

// dev
...
plugin: {
  dashboard: {
    plugin: DashboardPlugin
  },
  webpackLoaderOptions: {
    plugin: webpack.LoaderOptionsPlugin,
    args: [{
      debug: true
    }]
  },
  webpackHotModuleReplacement: {
    plugin: webpack.HotModuleReplacementPlugin
  },
  webpackNamedModules: {
    plugin: webpack.NamedModulesPlugin
  },
  webpackNoEmitOnErrors: {
    plugin: webpack.NoEmitOnErrorsPlugin
  },
  webpackOptimizeOccurrenceOrder: {
    plugin: webpack.optimize.OccurrenceOrderPlugin
  },
  progressBar: {
    plugin: ProgressBarPlugin,
    args: [{
      format: `build [:bar] ${chalk.green.bold(':percent')}  (:elapsed 秒)`,
      complete: '>',
      incomplete: '-',
      clear: false
    }]
  },
  html: {
    plugin: HtmlWebpackPlugin,
    args: [{
      filename: `${projectConfig.htmlName ? projectConfig.htmlName : 'index'}.html`,
      template,
      title: projectConfig.htmlTitle,
      inject: true,
      favicon: projectConfig.favicon && path.resolve(projectConfig.path, projectConfig.favicon)
    }]
  }
},
...

// prod
...
plugin: {
  clean: {
    plugin: CleanWebpackPlugin,
    args: [{
      // dry: true,
      verbose: true
    }]
  },
  uglifyJs: {
    plugin: UglifyJsPlugin,
    args: [{
      uglifyOptions: {
        compress: true,
        cache: true,
        ie8: false,
        parallel: true,
        output: {
          comments: false,
          beautify: false
        },
        sourceMap: config.prod.sourceMap,
        warnings: false
      }
    }]
  },
  html: {
    plugin: HtmlWebpackPlugin,
    args: [{
      filename: `${projectConfig.htmlName ? projectConfig.htmlName : 'index'}.html`,
      template,
      title: projectConfig.htmlTitle,
      inject: true
    }]
  }
}
...

Started

Cli

vue2do-build dev projectPath/project.config.js

vue2do-build prod projectPath/project.config.js

Require

const vue2doBuild = require('@vue2do/build')

vue2doBuild.dev({
  config: {
    httpsOpt: false
  },
  configPath: path.resolve(__dirname, '../project.config.js')
})

vue2doBuild.prod({
  config: {
    httpsOpt: false
  },
  configPath: path.resolve(__dirname, '../project.config.js')
})

Method

getConfig

return: base | dev | prod

const configuration = getConfig({
  config: {
    path: path.dirname(projectConfigPath)
  }
})