【发布时间】:2018-11-13 21:42:37
【问题描述】:
我正在 Mac 上开发这个 nuxtjs 项目(所有最新最好的),本地构建和生成工作正常。我使用sass-loader 作为开发依赖项,而我的nuxt.config.js 文件与默认文件没有太大区别:
module.exports = {
head: {
title: 'temp-www',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Nuxt.js project' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
modules: [
[ 'nuxt-fontawesome', {
component: 'fa',
imports: [
{ set: '@fortawesome/fontawesome-free-brands' },
]
}],
],
loading: { color: '#3B8070' },
build: {
extend (config, { isDev, isClient }) {
if (isDev && isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
}
}
}
然后我像这样创建了一个Dockerfile
FROM node:stretch
ENV NODE_ENV=production
ENV HOST=0.0.0.0
RUN mkdir -p /app
COPY . /app
WORKDIR /app
EXPOSE 3000
RUN npm install
RUN npm run build
CMD ["npm", "start"]
(和适当的.dockerignore)但在构建图像时出现以下错误。
ERROR in ./layouts/default.vue
Module not found: Error: Can't resolve 'sass-loader' in '/app/layouts'
@ ./layouts/default.vue 2:2-436
@ ./.nuxt/App.js
@ ./.nuxt/index.js
@ ./.nuxt/client.js
在那里和其他.vue 文件中,我在<style lang="scss"> 之类的块中使用sass。我尝试将其更改为sass,但没有任何区别。
奇怪的是,this question 说它应该通过将sass-loader 和 node-sass 作为运行时部门而不是 devtime 部门来工作。我对此持怀疑态度,但情况变得更糟,直到我将style 块中的lang 属性更改为scss 而不是sass。在这种情况下,并且仅在这种情况下,我正确构建了图像。
我错过了什么?
【问题讨论】: