- https://cli.vuejs.org/config/#configurewebpack https://cli.vuejs.org/config/#configurewebpack
- https://cli.vuejs.org/config/#chainwebpack https://cli.vuejs.org/config/#chainwebpack
我试过了:
chainWebpack: config => {
config.merge({
module: {
rules: [{
test: /\.jsx?$/,
exclude: {
exclude: [path.resolve(__dirname, "public/my-config.js")]
}
}]
}
})
}
Or
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/
以便可以对其进行编辑。
参考:
- https://github.com/neutrinojs/webpack-chain#config-plugins-modify-arguments https://github.com/neutrinojs/webpack-chain#config-plugins-modify-arguments
- https://github.com/webpack-contrib/copy-webpack-plugin#ignore https://github.com/webpack-contrib/copy-webpack-plugin#ignore
我在我的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'
]
}
]]
);
}
}
I used $ vue inspect > output.js
然后检查了output.js
文件用于了解哪些参数config.plugin('copy')
这恰好是一个实例new CopyWebpackPlugin
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)