Created
April 1, 2018 16:09
-
-
Save wzup/bf6e374135617242d7f2081bcba75c52 to your computer and use it in GitHub Desktop.
WP config
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
'use strict'; | |
const util = require('util'); | |
let NODE_ENV = process.env.NODE_ENV || 'development'; | |
const webpack = require('webpack'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const autoprefixer = require('autoprefixer'); | |
const path = require('path'); | |
var isDebug = true; | |
module.exports = { | |
resolve: { | |
extensions: ['*', '.js', '.jsx', '.json'], | |
}, | |
entry: [ | |
path.resolve(__dirname, 'src/index.js') // Defining path seems necessary for this to work consistently on Windows machines. | |
], | |
output: { | |
path: path.resolve(__dirname, 'dist'), // Note: Physical files are only output by the production build task `npm run build`. | |
publicPath: '/', | |
filename: 'bundle-[name].js', | |
}, | |
module: { | |
rules: [ | |
{ test: /\.jsx?$/, exclude: /node_modules/, loaders: ['babel-loader'] }, | |
{ | |
test: /\.(gif|png|jpe?g|svg)$/i, | |
use: [ | |
'file-loader', | |
{ | |
loader: 'image-webpack-loader', | |
options: { | |
bypassOnDebug: true, | |
}, | |
}, | |
], | |
}, | |
{ | |
test: /\.ico$/, | |
loader: 'file-loader?name=[name].[ext]' | |
}, | |
{ | |
test: /\.scss$/, | |
exclude: [/theme.scss$/, /application.scss$/], | |
use: [ | |
'isomorphic-style-loader', | |
`css-loader?${isDebug ? 'sourceMap&' : 'minimize&'}modules&localIdentName=${isDebug ? '[name]_[local]_[hash:base64:3]' : '[hash:base64:4]'}&importLoaders=2`, | |
{ | |
loader: 'postcss-loader', | |
options: { | |
path: path.resolve(__dirname), | |
} | |
}, | |
'sass-loader', | |
], | |
}, | |
{ | |
test: /\.css$/, | |
use: [{ | |
loader: "style-loader", | |
}, | |
{ | |
loader: 'css-loader', | |
options: { | |
importLoaders: 1, | |
sourceMap: isDebug, | |
minimize: !isDebug, | |
discardComments: { | |
removeAll: true | |
}, | |
}, | |
}, | |
{ | |
loader: 'postcss-loader', | |
options: { | |
config: { | |
path: path.resolve(__dirname), | |
} | |
} | |
} | |
], | |
}, | |
] | |
}, | |
plugins: [ | |
new webpack.DefinePlugin({ | |
'process.env.NODE_ENV': JSON.stringify('development'), | |
__DEV__: true, | |
AUTHOR: "Sergey Reznikov", | |
SERVICE_URL: JSON.stringify("http://dev.example.com") | |
}), | |
new webpack.NoEmitOnErrorsPlugin(), | |
new HtmlWebpackPlugin({ | |
template: 'src/index.ejs', | |
minify: { | |
removeComments: true, | |
collapseWhitespace: true | |
}, | |
inject: true | |
}), | |
], | |
target: 'web', | |
devtool: 'eval-source-map', | |
mode: NODE_ENV, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment