我试过了:
chainWebpack: config => {
config.merge({
module: {
rules: [{
test: /\.jsx?$/,
exclude: {
exclude: [path.resolve(__dirname, "public/my-config.js")]
}
}]
}
})
}
或者
config.module.rule('js')
.exclude({
exclude: path.resolve(__dirname, "public/my-config.js")
})
但它不起作用。
我想导入
public/my-config.js
pages/index.html
中带有脚本标记或只是 import { config1, config2 } from '../public/my-config'
.我可以使用
externals
虽然在 webpack 中不包含模块,但 Vue.js 不太直观。我必须有
my-config.js
可在 dist/
获得以便可以对其进行编辑。
最佳答案
引用:
我在
vue.config.js
中写的内容:const path = require("path");
module.exports = {
baseUrl: ".",
chainWebpack: config => {
config.plugin('copy').tap((args) => [[
{
from: '/path/to/my_project/public',
to: '/path/to/my_project/dist',
toType: 'dir',
ignore: [
'index.html',
'.DS_Store',
'config.data.js'
]
}
]]
);
}
}
我用了
$ vue inspect > output.js
然后检查了output.js
config.plugin('copy')
使用了哪些参数的文件恰好是 new CopyWebpackPlugin
的一个实例.
关于vue.js - 如何在 Vue.js 中排除文件(例如配置文件)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53035036/