Skip to content

Instantly share code, notes, and snippets.

@ravloony
Last active December 13, 2018 06:33
Show Gist options
  • Save ravloony/7aa64ef4cd10dadedcd649627e1144ab to your computer and use it in GitHub Desktop.
Save ravloony/7aa64ef4cd10dadedcd649627e1144ab to your computer and use it in GitHub Desktop.
Purescript webpack config
{
"name": "something",
"version": "0.0.1",
"description": "Something",
"main": "bundle.js",
"directories": {
"test": "test"
},
"dependencies": {
},
"scripts": {
"webpack": "DEBUG=purs-loader webpack --progress --bail",
"webpack:watch": "DEBUG=purs-loader webpack --progress --display-error-details --watch",
"webpack:server": "webpack-dev-server --progress --inline --hot",
"webpack:server:debug": "DEBUG=purs-loader webpack-dev-server --progress --inline --hot",
"start": "node bundle.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "",
"devDependencies": {
"webpack": "3.0.0",
"webpack-build-notifier": "^0.1.13",
"webpack-dev-server": "^2.4.5",
"purescript-psa": "^0.5.1",
"purs-loader": "^2.4.2",
}
}
'use strict';
const path = require('path');
const webpack = require('webpack');
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
var WebpackBuildNotifierPlugin = require('webpack-build-notifier');
const isWebpackDevServer = process.argv.filter(a => path.basename(a) === 'webpack-dev-server').length;
const isWatch = process.argv.filter(a => a === '--watch').length
module.exports = {
devtool: 'eval-source-map',
devServer: {
contentBase: '.',
host: "0.0.0.0",
port: 8182,
stats: 'errors-only',
disableHostCheck: true
},
entry: {
front: './src/main.js',
admin: './src/admin.js',
users: './src/users.js'
},
output: {
path: __dirname + '/assets/js',
pathinfo: true,
filename: '[name].bundle.js',
chunkFilename: '[id].chunk.js'
},
module: {
rules: [
{
test: /\.purs$/,
loader: 'purs-loader',
query: {
src: [ 'bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs' ],
bundle: false,
psc: 'psa',
watch: isWebpackDevServer || isWatch,
pscIde: false
}
},
]
},
resolve: {
modules: [ 'node_modules', 'bower_components' ],
extensions: [ '.purs', '.js']
},
plugins: (isWebpackDevServer || !isWatch ? [
new webpack.LoaderOptionsPlugin({
debug: true
})
] : [
function(){
this.plugin('done', function(stats){
process.stderr.write(stats.toString('errors-only'));
});
}
]).concat([
new CommonsChunkPlugin({
filename: "common.js",
name: "common"
}),
new WebpackBuildNotifierPlugin({ title: 'Secure Space' }),
new webpack.optimize.ModuleConcatenationPlugin(),
])
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment