Created
April 11, 2017 22:35
-
-
Save jaburns/6b84cd1b019379ad06df8f2d1d62cc40 to your computer and use it in GitHub Desktop.
Example of building only sass with webpack for legacy project
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 isProduction = process.env.NODE_ENV === 'production'; | |
module.exports = { | |
context: __dirname, | |
entry: { | |
styles: ['./sass/main.scss'] | |
}, | |
output: { | |
filename: 'build.css' | |
}, | |
module: { | |
loaders: [{ | |
test: /\.scss$/, | |
loader: isProduction | |
? 'css-loader!sass-loader' | |
: 'css-loader?sourceMap!sass-loader?outputStyle=expanded&sourceMap=true&sourceMapContents=true' | |
}] | |
} | |
}; |
I know this a bit old, but I had the same problem a few months ago of a JS file being generated for every CSS and I solved it using this plugin: https://github.com/fqborges/webpack-fix-style-only-entries#readme. This plugin removes the unnecessary JavaScript file.
Here is the version I made from @jakeguti's suggestion.
https://www.dotnetthailand.com/to-other-languages/typescript-for-c-sharp-developers/webpack-configuration-for-sass-only
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It puts a JS code to the
build.css
file, doesn't it?