| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- const { merge } = require('webpack-merge')
- const { resolve } = require('path')
- const moment = require('moment')
- const { defineConfig } = require('@vue/cli-service')
- const tsImportPluginFactory = require('ts-import-plugin')
- module.exports = defineConfig({
- transpileDependencies: true,
- productionSourceMap: false, // 打包取消.map
- publicPath: './',
- pages: {
- indexPath: {
- entry: process.env.VUE_APP_ROOT + 'main.ts',
- template: process.env.VUE_APP_ROOT + 'index.html',
- filename: 'index.html',
- title: process.env.VUE_APP_TITLE,
- meta: {
- revised: moment(new Date()).format('YYYYMMDDHHmmss') // 打包生成版本号
- }
- }
- },
- chainWebpack: (config) => {
- config.resolve.alias
- .set('@' + process.env.VUE_APP_ENV, resolve(__dirname, process.env.VUE_APP_ROOT))
- config.module
- .rule('ts')
- .use('ts-loader')
- .tap((options) => {
- options = merge(options, {
- transpileOnly: true,
- getCustomTransformers: () => ({
- before: [
- // vant 按需引入
- tsImportPluginFactory({
- libraryName: 'vant',
- libraryDirectory: 'es',
- style: true
- })
- ],
- compilerOptions: {
- module: 'es2015'
- }
- })
- })
- return options;
- })
- }
- })
|