Created
April 3, 2018 22:49
-
-
Save JohannesFischer/2508b6027f7e7dc7ac52c96c273e5cf3 to your computer and use it in GitHub Desktop.
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'); | |
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