Skip to content

Instantly share code, notes, and snippets.

@gkatsanos
Created April 23, 2017 10:44
Show Gist options
  • Save gkatsanos/b8aa1871a60dddc5d89aed6ba01550a4 to your computer and use it in GitHub Desktop.
Save gkatsanos/b8aa1871a60dddc5d89aed6ba01550a4 to your computer and use it in GitHub Desktop.
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
const exclude = /node_modules/;
const webpack = require('webpack');
module.exports = {
entry: {
"js/bundle": "./js/src/main",
"css/main": "./sass/main.scss",
"css/frontpage": "./sass/frontpage.scss"
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "./dist"),
hotUpdateChunkFilename: 'hot-update.js',
hotUpdateMainFilename: 'hot-update.json'
},
module: {
rules: [
{
test: /\.js$/,
enforce: "pre",
exclude: exclude,
use: [
"babel-loader",
"eslint-loader"
]
},
{ test: /\.(jpg|png|svg)$/, loader: 'file-loader?name=[name].[ext]?[hash]&publicPath=../&outputPath=images/' },
{ test: /\.(woff|woff2|eot|ttf)$/, loader: 'file-loader?name=[name].[ext]?[hash]&publicPath=../&outputPath=fonts/' },
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'postcss-loader'],
})
},
{
test: /\.s[ac]ss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: "css-loader",
options: {
importLoaders: 1,
sourceMap: true
}
},
{
loader: "sass-loader",
options: {
sourceMap: true,
includePaths: [
path.resolve(__dirname, './node_modules/bootstrap-sass/assets/stylesheets'),
]
}
},
],
})
}
]
},
devtool: "source-map",
devServer: {
contentBase: path.join(__dirname, "/"),
publicPath: "/themes/rocket/dist/",
port: 9000,
hot: true,
proxy: {
"/": "http://ops.rocket-internet.dev/"
}
},
plugins: [
new ExtractTextPlugin({ // define where to save the file
filename: "./[name].css",
allChunks: true,
}),
new webpack.HotModuleReplacementPlugin()
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment