Skip to content

Instantly share code, notes, and snippets.

@JohannesFischer
Created April 3, 2018 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohannesFischer/2508b6027f7e7dc7ac52c96c273e5cf3 to your computer and use it in GitHub Desktop.
Save JohannesFischer/2508b6027f7e7dc7ac52c96c273e5cf3 to your computer and use it in GitHub Desktop.
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
context: __dirname,
mode: process.env.NODE_ENV || 'production',
entry: {
app: [
'./app/js/index.js',
'./app/styles/styles.css'
]
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: [
["env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
}
}]
]
}
},
exclude: path.join(__dirname, 'node_modules')
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
importLoaders: 1
}
},
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
// parser: scss,
plugins: [
require('postcss-import')({ root: path.join(__dirname, 'app/styles'), }),
require('postcss-cssnext')({ browsers: [ 'last 2 versions' ] }),
require('postcss-nesting')(),
require('postcss-inline-svg')(),
require('cssnano')()
]
}
}
]
})
},
{
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
loader: 'file-loader'
}
]
},
plugins: [
new ExtractTextPlugin('[name].css')
],
resolve: {
alias: {
// add aliases
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment