– style.scssをmain.jsにバンドルさせる
– webpack, webpack-cli, webpack-dev-server, style-loader, css-loaderインストール済
### Sassモジュールインストール
$ npm i -D sass sass-loader
### webpack.config.js
– scssファイル -> sass-loader -> css-loader -> style-loader
const MODE = "development"; const enabledSourceMap = MODE === "development"; module.exports = { entry: `./src/index.js`, output: { filename: "main.js" }, devServer: { host: '192.168.33.10', port: '8000', contentBase: "dist", open: true }, module: { rules: [ { test: /\.scss/, use: [ "style-loader", { loader: "css-loader", options: { url: false, sourceMap: enabledSourceMap, // 0 => no loaders(default); // 1 => postcss-loader; // 2 => postcss-loader, sass-loader; importLoaders: 2 } }, { loader: "sass-loader", options: { sourceMap: enabledSourceMap } } ] } ] } };
/src/style.scss
/src/index.js
import "./style.scss";
$ npm run build