-
-
Save vladhd93/5d82af3feb80a5a3d8fc16f6ab27bcba 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 webpack = require('webpack'); | |
const path = require('path'); | |
const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); | |
require('babel-polyfill'); | |
const extractCommons = new webpack.optimize.CommonsChunkPlugin({ | |
name: 'commons', | |
filename: 'commons.js', | |
minChunks:2 | |
}); | |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
const extractCSS = new ExtractTextPlugin('[name].css'); | |
const config = { | |
context: __dirname, | |
entry: { | |
app: './apps/utils/react/app.js', | |
}, | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: '[name].js', | |
}, | |
resolve: { | |
modules: ['node_modules', 'apps/utils/react'], | |
extensions: ['.js', '.jsx', '.json'], | |
alias: { | |
'common-scss': path.resolve(__dirname, 'apps/utils/react/scss'), | |
countries: path.resolve(__dirname, 'countries.json'), | |
}, | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.svg$/, | |
loader: 'svg-url-loader', | |
}, | |
{ | |
test: /\.json$/, | |
loader: 'json-loader', | |
}, | |
{ | |
test: /\.js$/, | |
exclude: /node_modules(?!\/webpack-dev-server)/, | |
include: __dirname, | |
use: [ | |
{ | |
loader: 'babel-loader', | |
options: { | |
presets: [['env', { modules: false }]], | |
}, | |
}, | |
], | |
}, | |
{ | |
test: /\.(png|jpg)$/, | |
use: [ | |
{ | |
loader: 'url-loader', | |
options: { limit: 10000 }, // Convert images < 10k to base64 strings | |
}, | |
], | |
}, | |
{ | |
test: /\.scss|css$/, | |
use: [ | |
{ | |
loader: 'file-loader', | |
options: { | |
name: '[name].css', | |
context: './', | |
outputPath: '', | |
publicPath: './', | |
}, | |
}, | |
{ loader: 'autoprefixer-loader' }, | |
{ | |
loader: 'extract-loader', | |
}, | |
{ | |
loader: 'css-loader', | |
options: { | |
sourceMap: true, | |
minimize: true, | |
}, | |
}, | |
{ | |
loader: 'resolve-url-loader', | |
}, | |
{ | |
loader: 'sass-loader', | |
options: { | |
sourceMap: true, | |
}, | |
}, | |
], | |
}, | |
], | |
}, | |
plugins: [extractCommons, extractCSS,new UglifyJsPlugin({ | |
test: /\.js($|\?)/i, | |
sourceMap: true, | |
uglifyOptions: { | |
compress: true | |
} | |
})], | |
}; | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment