project/
├── dist/
├── src/
│ ├── main.js
│ └── main.scss
└── index.html
Created
February 4, 2018 12:04
-
-
Save pavelruzicka/085bb8183f792ae52f3765efad1d8e26 to your computer and use it in GitHub Desktop.
Using Webpack to compile Sass
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
| <!-- | |
| <script src="dist/bundle.js"></script> | |
| --> | |
| <link rel="stylesheet" href="dist/main.css"> | |
| <h1>Hello world!</h1> |
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
| require('./main.scss'); |
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
| $test: tomato; | |
| h1 { | |
| font-style: italic; | |
| color: $test; | |
| } |
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": "", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "src/main.js", | |
| "scripts": { | |
| "start": "webpack-dev-server", | |
| "build": "webpack -p" | |
| }, | |
| "author": "", | |
| "license": "ISC", | |
| "devDependencies": { | |
| "css-loader": "^0.28.4", | |
| "extract-text-webpack-plugin": "^2.1.2", | |
| "node-sass": "^4.5.3", | |
| "sass-loader": "^6.0.6", | |
| "webpack": "^3.0.0", | |
| "webpack-dev-server": "^2.5.0" | |
| } | |
| } |
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
| var path = require('path'); | |
| var ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
| var extractPlugin = new ExtractTextPlugin({ | |
| filename: 'main.css' | |
| }); | |
| module.exports = { | |
| entry: './src/main.js', | |
| output: { | |
| path: path.resolve(__dirname, 'dist'), | |
| filename: 'bundle.js', | |
| publicPath: '/dist' | |
| }, | |
| module: { | |
| rules: [ | |
| { | |
| test: /\.scss$/, | |
| use: extractPlugin.extract({ | |
| use: ['css-loader', 'sass-loader'] | |
| }) | |
| } | |
| ] | |
| }, | |
| plugins: [ | |
| extractPlugin | |
| ] | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment