2017-07-01 21:26:26 +03:00
|
|
|
const appConfig = require('./src/Guide/Config.js').config
|
2017-07-01 17:56:09 +03:00
|
|
|
const spawn = require('child_process').spawn
|
|
|
|
const path = require('path')
|
|
|
|
const webpack = require('webpack')
|
|
|
|
const isProd = process.env.NODE_ENV === 'production'
|
|
|
|
|
2017-07-02 18:49:40 +03:00
|
|
|
const entries = [ path.join(__dirname, 'src/index.client.js')]
|
2017-07-01 17:56:09 +03:00
|
|
|
|
|
|
|
const plugins = [
|
2017-07-02 18:49:40 +03:00
|
|
|
new webpack.ProgressPlugin(),
|
2017-07-01 17:56:09 +03:00
|
|
|
new webpack.DefinePlugin({
|
2017-07-01 21:26:26 +03:00
|
|
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
|
|
'$PRODUCTION': isProd,
|
|
|
|
'$SERVER': false
|
2017-07-01 17:56:09 +03:00
|
|
|
}),
|
|
|
|
]
|
|
|
|
|
|
|
|
if (isProd) {
|
|
|
|
plugins.push(
|
|
|
|
new webpack.LoaderOptionsPlugin({
|
|
|
|
minimize: true,
|
|
|
|
debug: false
|
|
|
|
})
|
|
|
|
)
|
|
|
|
} else {
|
2017-07-04 20:35:08 +03:00
|
|
|
entries.unshift(`webpack-hot-middleware/client?path=http://localhost:8080/__webpack_hmr&reload=true`);
|
2017-07-01 17:56:09 +03:00
|
|
|
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
|
|
|
|
},
|
2017-07-01 21:26:26 +03:00
|
|
|
plugins: plugins,
|
2017-07-01 17:56:09 +03:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2017-07-04 20:35:08 +03:00
|
|
|
module.exports = config
|