Webpack“找不到module test.scss”

我在Docker容器中运行webpack,如果这有什么区别的话。

我的webpack.config.js:

module.exports = { entry: './app/Resources/scripts/test.js', output: { filename: './web/js/bundle.js' }, watch: true, module: { rules: [{ test: /\.scss$/, use: [{ loader: "style-loader" // creates style nodes from JS strings }, { loader: "css-loader" // translates CSS into CommonJS }, { loader: "sass-loader" // compiles Sass to CSS }] }] } } 

我的test.js:

 require('../styles/test.scss'); alert('Hello'); 

我的文件结构:

 app/ --Resources/ ----scripts/ ------test.js ----styles/ ------test.scss web/ --js/ ----bundle.js webpack.config.js 

我的dockerfile是:

 FROM ubuntu:latest WORKDIR /app RUN apt-get update RUN apt-get install curl -y RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - && apt-get install nodejs -y RUN npm install webpack sass-loader css-loader style-loader node-sass -g CMD webpack 

JS编译好,工作等,但是当试图编译SCSS失败,错误:

webpack_require (!(function webpackMissingModule(){var e = new Error(“Can not find module \”../ styles / test.scss \“”); e.code ='MODULE_NOT_FOUND'; throw e;}())) ;