Last active
June 27, 2022 01:12
-
-
Save mamift/8aa61fbd271d60748f73ff678182fcdd to your computer and use it in GitHub Desktop.
webpack 5 and npm package.json configuration file for SASS only entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "sass-only-webpack-example", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "index.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1", | |
| "build": "webpack --config webpack.config.js" | |
| }, | |
| "author": "", | |
| "license": "ISC", | |
| "devDependencies": { | |
| "css-loader": "^6.7.1", | |
| "mini-css-extract-plugin": "^2.6.1", | |
| "node-sass": "^7.0.1", | |
| "sass-loader": "^13.0.1", | |
| "style-loader": "^3.3.1", | |
| "webpack": "^5.73.0", | |
| "webpack-cli": "^4.10.0", | |
| "webpack-fix-style-only-entries": "^0.6.1" | |
| }, | |
| "dependencies": {} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const path = require('path'); | |
| const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries'); | |
| const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | |
| module.exports = [ | |
| { | |
| mode: process.env.NODE_ENV, | |
| entry: { | |
| 'site': './Content/site.scss', | |
| }, | |
| module: { | |
| rules: [ | |
| { | |
| test: /\.scss$/, | |
| exclude: /(node_modules|bower_components)/, | |
| use: [ | |
| { | |
| loader: MiniCssExtractPlugin.loader, | |
| }, | |
| { | |
| loader: 'css-loader', | |
| options: { | |
| sourceMap: true, | |
| url: false, | |
| }, | |
| }, | |
| 'sass-loader', | |
| ], | |
| }, | |
| ], | |
| }, | |
| devtool: 'source-map', | |
| // defaults to outputing to ./dist folder; use the ../ operator to output to a folder adjacent to ./dist | |
| plugins: [new FixStyleOnlyEntriesPlugin(), new MiniCssExtractPlugin({filename: '../Content/site.css'})], | |
| }, | |
| ]; | |
| /* package.json dev depenendies: | |
| "devDependencies": { | |
| "css-loader": "^6.7.1", | |
| "mini-css-extract-plugin": "^2.6.1", | |
| "node-sass": "^7.0.1", | |
| "sass-loader": "^13.0.1", | |
| "style-loader": "^3.3.1", | |
| "webpack": "^5.73.0", | |
| "webpack-cli": "^4.10.0", | |
| "webpack-fix-style-only-entries": "^0.6.1" | |
| }, | |
| test on Windows 10, node.js v13.14.0 | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment