我正在使用vue cli 3,这是我的vue.config.js
const path = require('path')
const webpack = require('webpack')
const publicDir = 'public'
const isProduction = process.env.NODE_ENV === 'production'
module.exports = {
publicPath: isProduction ? './dist/' : '',
outputDir: 'public/dist',
indexPath: '../../resources/views/index.blade.php',
filenameHashing: true,
chainWebpack: config => {
config
.entry('app')
.clear()
.add('./resources/vue/main.js')
.end()
config.module
.rule('graphql')
.test(/\.gql$/)
.use('graphql-tag/loader')
.loader('graphql-tag/loader')
.end()
},
configureWebpack: {
plugins: [new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)]
}
}我需要在生成后删除一些文件以供生产,而且我不知道如何在上检测构建过程。
我没有找到任何这方面的文件。
发布于 2019-08-19 12:19:30
您可以在您的package.json文件中这样做。您可以添加自定义脚本或修改现有脚本。
例如,看看干净的脚本。您可以手动调用此脚本,也可以将其添加到其他脚本中。在本例中,当执行build脚本时执行:
"scripts": {
"serve": "vue-cli-service serve",
"watch": "vue-cli-service build --mode development --watch",
"dev": "vue-cli-service --mode development build",
"build": "vue-cli-service build && npm run clean",
"lint": "vue-cli-service lint",
"clean": "rm -rf ../public/dist"
},
...clean注意::&&使它们按顺序运行,&&将在 build.之后运行
发布于 2019-10-16 05:45:28
添加一个postbuild脚本如何:
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"postbuild": "rm dist/<file-to-delete>", // <--- add this one
"lint": "vue-cli-service lint",
"test:e2e": "vue-cli-service test:e2e",
"test:unit": "vue-cli-service test:unit"
}https://stackoverflow.com/questions/57556194
复制相似问题