Skip to content

Instantly share code, notes, and snippets.

@alexander-daniel
Last active March 5, 2018 19:22
Show Gist options
  • Save alexander-daniel/e32e2bf912e9d4e4158b8040057bcc1d to your computer and use it in GitHub Desktop.
Save alexander-daniel/e32e2bf912e9d4e4158b8040057bcc1d to your computer and use it in GitHub Desktop.
example sass and js build in same webpack
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