1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-24 05:13:50 +03:00
guide/front-ps/webpack.config.client.js
2017-07-04 19:35:08 +02:00

91 lines
1.9 KiB
JavaScript

const appConfig = require('./src/Guide/Config.js').config
const spawn = require('child_process').spawn
const path = require('path')
const webpack = require('webpack')
const isProd = process.env.NODE_ENV === 'production'
const entries = [ path.join(__dirname, 'src/index.client.js')]
const plugins = [
new webpack.ProgressPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'$PRODUCTION': isProd,
'$SERVER': false
}),
]
if (isProd) {
plugins.push(
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
})
)
} else {
entries.unshift(`webpack-hot-middleware/client?path=http://localhost:8080/__webpack_hmr&reload=true`);
plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
)
}
const config = {
entry: entries,
context: __dirname,
target: 'web',
output: {
path: path.join(__dirname, 'static', 'dist'),
filename: 'bundle.js',
publicPath: appConfig.public_path
},
plugins: plugins,
module: {
loaders: [
{
test: /\.purs$/,
loader: 'purs-loader',
exclude: /node_modules/,
query: isProd ? {
bundle: true,
bundleOutput: 'static/dist/bundle.js'
} : {
psc: 'psa',
pscIde: true
}
}
],
},
resolveLoader: {
modules: [
path.join(__dirname, 'node_modules')
]
},
resolve: {
alias: {
'react': 'preact-compat',
'react-dom': 'preact-compat'
},
modules: [
'node_modules',
'bower_components'
],
extensions: ['.js', '.purs']
},
performance: { hints: false },
stats: {
hash: false,
timings: false,
version: false,
assets: false,
errors: true,
colors: false,
chunks: false,
children: false,
cached: false,
modules: false,
chunkModules: false
}
}
module.exports = config