Webpack“找不到模块test.scss”

时间:2017-07-24 15:23:32

标签: javascript docker webpack sass-loader

我在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(“找不到模块\”../ styles / test.scss \“”); e.code ='MODULE_NOT_FOUND ';扔e;}()));

0 个答案:

没有答案
相关问题