On Erev Shabbat, one must prioritize the Hanukkah candle before the Shabbat candle. And it is not only necessary if one accepts the Shabbat through the Shabbat candle, for then it is forbidden for him to light further, but even if he does not accept Shabbat with his lighting – nevertheless, it is impossible to light the Shabbat candle before the Hanukkah candle, as it is not fitting after the lighting of the Shabbat candle to perform mundane work. And also in the time of the Shas, it is implied that the lighting of the candle was the final labor (as the Ran, of blessed memory, elaborated in the second chapter). And so it is implied from the language of the Tur, that the Bahag rules that the Hanukkah candle precedes that of Shabbat, because through the lighting he accepted Shabbat. And he wrote that the Tosafot wrote that the acceptance is not dependent on the lighting, and he may light the Shabbat candle first etc. Thus far his words. That is to say: that by the letter of the law he may light the Shabbat candle first, but nevertheless it is better to light the Hanukkah candle first (and so wrote the Bach, see there).
בערב שבת צריך להקדים נר חנוכה לנר שבת. ולא מיבעיא אם מקבל את השבת על ידי נר שבת, דאז אסור לו להדליק עוד, אלא אפילו אינו מקבל שבת בהדלקתו – מכל מקום אי אפשר להדליק של שבת קודם לשל חנוכה, דלא נאה אחר הדלקת נר של שבת לעשות מלאכת חול. וגם בזמן הש"ס משמע שהדלקת הנר היתה מלאכה האחרונה (כמו שהאריך הר"ן ז"ל בפרק שני). וכן משמע מלשון הטור, דהבה"ג פוסק דנר חנוכה קודם לשל שבת, משום דבהדלקה קבל שבת. וכתב שהתוספות כתבו שאין הקבלה תלויה בהדלקה, ויכול להדליק של שבת תחילה וכו', עד כאן לשונו. כלומר: שמדינא יכול להדליק מקודם נר של שבת, אך מכל מקום טוב יותר להדליק של חנוכה מקודם (וכן כתב הב"ח, עיין שם).