Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global.Promise = require('bluebird');
- var webpack = require('webpack');
- var path = require('path');
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
- const { CleanWebpackPlugin } = require('clean-webpack-plugin');
- var publicPath = 'http://localhost:8050/public/assets';
- var cssName = process.env.NODE_ENV === 'production' ? 'styles-[hash].css' : 'styles.css';
- var jsName = process.env.NODE_ENV === 'production' ? 'bundle-[hash].js' : 'bundle.js';
- var plugins = [
- new webpack.DefinePlugin({
- 'process.env': {
- BROWSER: JSON.stringify(true),
- NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
- }
- }),
- new MiniCssExtractPlugin({
- // Options similar to the same options in webpackOptions.output
- // all options are optional
- filename: cssName,
- chunkFilename: '[id].css',
- ignoreOrder: false, // Enable to remove warnings about conflicting order
- }),
- new webpack.LoaderOptionsPlugin({
- options: {
- eslint: {
- configFile: '.eslintrc'
- }
- }
- })
- ];
- if (process.env.NODE_ENV === 'production') {
- plugins.push(
- new CleanWebpackPlugin({
- verbose: true,
- dry: false
- })
- );
- plugins.push(new webpack.optimize.OccurrenceOrderPlugin());
- }
- module.exports = {
- entry: ['babel-polyfill', './src/client.js'],
- //debug: process.env.NODE_ENV !== 'production',
- resolve: {
- modules: [__dirname, 'node_modules'],
- extensions: ['*', '.js', '.jsx']
- },
- plugins,
- output: {
- path: `${__dirname}/public/assets/`,
- filename: jsName,
- publicPath
- },
- module: {
- rules: [
- {
- test: /\.css$/,
- use: [
- {
- loader: MiniCssExtractPlugin.loader,
- options: {
- // you can specify a publicPath here
- // by default it uses publicPath in webpackOptions.output
- publicPath: '../',
- hmr: process.env.NODE_ENV === 'development',
- },
- },
- 'css-loader',
- ],
- },
- /*{
- test: /\.less$/,
- loader: MiniCssExtractPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader')
- },*/
- { test: /\.gif$/, loader: 'url-loader?limit=10000&mimetype=image/gif' },
- { test: /\.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg' },
- { test: /\.png$/, loader: 'url-loader?limit=10000&mimetype=image/png' },
- { test: /\.svg/, loader: 'url-loader?limit=26000&mimetype=image/svg+xml' },
- { test: /\.(woff|woff2|ttf|eot)/, loader: 'url-loader?limit=1' },
- { test: /\.jsx?$/, loader: process.env.NODE_ENV !== 'production' ? 'babel-loader!eslint-loader' : 'babel-loader', exclude: [/node_modules/, /public/] },
- { test: /\.json$/, loader: 'json-loader' },
- ]
- },
- //devtool: process.env.NODE_ENV !== 'production' ? 'source-map' : null,
- devServer: {
- headers: { 'Access-Control-Allow-Origin': '*' }
- },
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement