Last active
March 5, 2018 19:22
-
-
Save alexander-daniel/e32e2bf912e9d4e4158b8040057bcc1d to your computer and use it in GitHub Desktop.
example sass and js build in same webpack
This file contains 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 ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
const jsEntryPath = path.resolve(__dirname, 'index.js'); | |
const sassEntryPath = path.resolve(__dirname, 'scss', 'style.scss'); | |
const outputPath = path.resolve(__dirname, 'static'); | |
const sassLoaderRule = { | |
test: /\.scss/, | |
loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) | |
}; | |
const babelLoaderRule = { | |
test: /\.js$/, | |
loader: 'babel-loader', | |
exclude: /node_modules/ | |
}; | |
module.exports = { | |
entry: [ | |
jsEntryPath, | |
sassEntryPath | |
], | |
output: { | |
path: outputPath, | |
filename: 'js/bundle.js' | |
}, | |
module: { | |
rules: [ | |
sassLoaderRule, | |
babelLoaderRule | |
] | |
}, | |
plugins: [ | |
new ExtractTextPlugin('css/style.css') | |
], | |
resolve: { | |
extensions: ['.js', '.jsx'] | |
}, | |
stats: { | |
assets: true, | |
modules: false | |
}, | |
devtool: 'cheap-module-source-map' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment