Skip to content

Instantly share code, notes, and snippets.

@yyyyaaa
Created June 14, 2017 17:22
Show Gist options
  • Save yyyyaaa/374a9f4142a5b39688203d3a7593bf99 to your computer and use it in GitHub Desktop.
Save yyyyaaa/374a9f4142a5b39688203d3a7593bf99 to your computer and use it in GitHub Desktop.
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractSass = ExtractTextPlugin({
filename: "[name].[contenthash].css",
disable: process.env.NODE_ENV === "development"
});
module.exports = {
entry: '/assets/main.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'public')
},
module: {
rules: [{
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader'
]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
'file-loader'
]
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: [{
loader: 'babel-loader',
options: {
presets: ['env']
}
},
{
loader: "jshint-loader"
}
]
},
{
test: /\.scss$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "postcss-loader" // autoprefixer css
}, {
loader: "sass-loader" // compiles Sass to CSS
}]
},
{
test: /\.css$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "postcss-loader" // autoprefixer css
}]
}
]
},
plugins: [
extractSass
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment