Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const path = require('path');
- const webpack = require('webpack');
- const autoprefixer = require('autoprefixer');
- const precss = require('precss');
- const mqpacker = require('css-mqpacker');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- module.exports = {
- entry: [
- 'react-hot-loader/patch',
- 'babel-polyfill',
- 'whatwg-fetch',
- 'webpack-dev-server/client?http://localhost:3000',
- 'webpack/hot/only-dev-server',
- './src/index',
- ],
- output: {
- path: path.resolve(process.cwd(), 'dist'),
- publicPath: '/',
- filename: 'app.[hash].js',
- },
- devtool: 'eval',
- module: {
- rules: [{
- test: /\.js$/,
- include: [
- path.resolve(process.cwd(), 'src'),
- ],
- use: [{
- loader: 'babel-loader',
- options: {
- presets: [['es2015', { modules: false }], 'stage-0', 'react'],
- plugins: ['transform-runtime', 'transform-object-rest-spread', 'react-hot-loader/babel'],
- },
- }],
- }, {
- test: /\.css$/,
- include: [
- path.resolve(process.cwd(), 'src'),
- ],
- use: [{
- loader: 'style-loader',
- }, {
- loader: 'css-loader',
- options: {
- modules: true,
- importLoaders: true,
- localIdentName: '[hash:base64:5]',
- },
- }],
- }, {
- test: /\.css$/,
- include: [
- path.resolve(process.cwd(), 'node_modules'),
- ],
- use: [{
- loader: 'style-loader',
- }, {
- loader: 'css-loader',
- options: {
- autoprefixer: false,
- },
- }],
- }, {
- test: /\.(jpe?g|png|gif|svg)$/,
- use: [{
- loader: 'file-loader',
- }, {
- loader: 'image-webpack',
- options: {
- progressive: true,
- optimizationLevel: 7,
- interlaced: false,
- pngquant: {
- quality: '65-90',
- speed: 4,
- },
- },
- }],
- }],
- },
- plugins: [
- new webpack.NamedModulesPlugin(),
- new webpack.HotModuleReplacementPlugin(),
- new webpack.ProgressPlugin(),
- new HtmlWebpackPlugin({
- hash: false,
- template: './index.html',
- }),
- new webpack.LoaderOptionsPlugin({
- test: /\.css$/,
- debug: true,
- options: {
- postcss: [
- precss(),
- autoprefixer({
- browsers: [
- 'last 3 version',
- 'ie >= 10',
- ],
- }),
- mqpacker(),
- ],
- context: path.join(__dirname, 'src'),
- output: {
- path: path.join(__dirname, 'dist'),
- },
- },
- }),
- ],
- };
Advertisement
Add Comment
Please, Sign In to add comment