vue使用npm run unit 时,can't resolve image
ERROR in ./~/css-loader?{"minimize":false}!./~/sass-loader/lib/loader.js?{}!./src/assets/styles/main.scss Module not found: Error: Can't resolve './assets/img/bg_network_purple.svg' in '/Users/wladimircoka/Documents/Develop/logahub/src/assets/styles' @ ./~/css-loader?{"minimize":false}!./~/sass-loader/lib/loader.js?{}!./src/assets/styles/main.scss 7:209572-209617 @ ./src/assets/styles/main.scss @ ./src ^\.\/(?!main(\.js)?$) @ ./test/unit/index.js 03 03 2017 01:20:52.238:INFO [karma]: Karma v1.5.0 server started at http://0.0.0.0:9876/ 03 03 2017 01:20:52.240:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency 03 03 2017 01:20:52.251:INFO [launcher]: Starting browser PhantomJS 03 03 2017 01:20:53.135:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket zQeZT4atqRJZ8DNgAAAA with id 75929886 PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR Error: Cannot find module "./assets/img/bg_network_purple.svg" at webpack:///src/assets/styles/main.scss:7:0 <- index.js:16980 PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 0 of 0 ERROR (0.187 secs / 0 secs)
解决方法:
test/unit/index.js
const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/)
修改为:
const srcContext = require.context('../../src', true, /^\.\/(?!main\.js$).+\.(js|vue)$/i)