我正在使用vuejs
&创建一个网络扩展程序vue-cli
。我添加了要使用vue-cli
s internal webpack
st 处理的内容脚本:
configureWebpack: {
entry: {
contentScript: "./src/contentScript/contentScript.js"
}
编译工作。我得到了contentScript.js
一个 webpack 捆绑的文件。但是,当我尝试使用以下方法加载此文件时:
chrome.tabs.executeScript({
file: "js/contentScript.js"
});
什么都没发生。事实上,即使contentScript.js
只有 contains console.log('test')
,它似乎也没有像webpack
我想象的那样得到处理,因为在浏览器控制台中执行脚本不会产生任何结果。
我在这里监督什么?从vue inspect
我可以看到以下webpack
规则js
:
/* config.module.rule('js') */
{
test: /\.m?jsx?$/,
exclude: [
function () { /* omitted long function */ }
],
use: [
{
loader: '/home/user/Coding/webext/node_modules/cache-loader/dist/cjs.js',
options: {
cacheDirectory: '/home/user/Coding/webext/node_modules/.cache/babel-loader',
cacheIdentifier: '356420a0'
}
},
{
loader: '/home/user/Coding/webext/node_modules/babel-loader/lib/index.js'
}
]
},