Я хочу использовать scss в своем проекте, однако, когда я строю свой проект с использованием веб-пакета, я получаю следующую ошибку.
ОШИБКА в ./src/public/app1/index.tsx Модуль не найден: Ошибка: Невозможно разрешить файл index.scss в папке / Users / k / portal / src / public / app1 '@ ./src/public/app1/index.tsx 10: 0-21 @ multi ./src/public / app1 / index.tsx
Пожалуйста, посмотрите мою конфигурацию веб-пакета.
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const WebpackShellPlugin = require('webpack-shell-plugin');
const CopyWebpackPlugin = require("copy-webpack-plugin");
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const {
NODE_ENV = 'development',
} = process.env;
module.exports = [{
entry: {
app1: ["./src/public/app1/index.tsx"],
app2: ["./src/public/app2/index.tsx"],
},
output: {
filename: "[name]/bundle.js",
path: path.resolve(__dirname, 'build/public/'),
},
// Enable sourcemaps for debugging webpack's output.
devtool: "source-map",
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".json", ".css", ".scss"]
},
module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" },
{
test: /(\.css|.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
}]
},
]
},
"plugins": [
new CleanWebpackPlugin(),
new CopyWebpackPlugin([
{
from: "src/public/app1/index.html",
to: "app1"
},
{
from: "src/public/app2/index.html",
to: "app2"
},
]),
],
// When importing a module whose path matches one of the following, just
// assume a corresponding global variable exists and use that instead.
// This is important because it allows us to avoid bundling all of our
// dependencies, which allows browsers to cache those libraries between builds.
externals: {
// "react": "React",
// "react-dom": "ReactDOM"
}
}]