2017-09-02 44 views
1

此任務看起來很簡單,但我一直無法弄清楚。無法在webpack中填充供應商js

我們的網站使用flowplayer,它可以通過NPM。但是,我們的網站使用商業版本,只能通過直接下載獲得。現在我們正在React中重建網站,我想要使用WebPack捆綁商業版本,但我一直在遇到問題。

通過

import flowplayer from '../vendor/flowplayer.js';

簡單地導入到一個組件產生的幾個誤區:

Line 7: 'handler' is not defined no-undef Line 7: 'handler' is not defined no-undef Line 7: 'handler' is not defined no-undef Line 7: 'handler' is not defined no-undef Line 7: Unexpected use of 'top' no-restricted-globals Line 8: Unexpected use of 'self' no-restricted-globals Line 8: Unexpected use of 'self' no-restricted-globals Line 451: Unexpected use of 'location' no-restricted-globals Line 3619: Unexpected use of 'location' no-restricted-globals Line 3619: Unexpected use of 'location' no-restricted-globals Line 3619: Unexpected use of 'location' no-restricted-globals Line 4875: Unexpected use of 'self' no-restricted-globals Line 4875: Unexpected use of 'self' no-restricted-globals

是否有任何理由爲什麼當node_modules目錄中,而不是在模塊分裝?

此外,由於此應用程序以前使用create-react-app構建,可能會有一些我不知道的默認限制嗎?

回答

2

這些是linting錯誤。你應該禁用你的供應商文件的分支 - 這是默認的,但由於你已經把它放在你的node_modules之外,你還需要添加供應商文件夾來忽略。

可以npm run eject和編輯webpack.config.dev/prod.js文件和test後的插件添加ignore或者您可以編輯該文件,使之忽略,比如像這樣:

https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments

/* eslint-disable */在流水遊戲文件的頂部。當然,你可以修復他們的錯誤...