]>
Commit | Line | Data |
---|---|---|
a42f24b8 | 1 | # purs-loader |
2 | ||
08b34471 | 3 | > [PureScript](http://www.purescript.org) loader for [webpack](http://webpack.github.io) |
a42f24b8 | 4 | |
7de41f10 AM |
5 | - Supports hot-reloading and rebuilding of single source files |
6 | - Dead code elimination using the `bundle` option | |
7 | - Colorized build output using `purescript-psa` and the `psc: "psa"` option | |
8 | ||
a42f24b8 | 9 | ## Install |
10 | ||
63d6a244 | 11 | Install with [npm](https://npmjs.org/package/purs-loader). |
12 | ||
a42f24b8 | 13 | ``` |
2d52ea7e | 14 | // For PureScript 0.9 and newer |
a9a26a84 | 15 | npm install purs-loader --save-dev |
2b2207bd | 16 | |
2d52ea7e | 17 | // Fore PureScript 0.8 |
689268da | 18 | npm install purs-loader@purescript-0.8 --save-dev |
a42f24b8 | 19 | ``` |
20 | ||
a42f24b8 | 21 | ## Example |
22 | ||
7de41f10 AM |
23 | ```javascript |
24 | const webpackConfig = { | |
25 | // ... | |
26 | loaders: [ | |
27 | // ... | |
28 | { | |
29 | test: /\.purs$/, | |
30 | loader: 'purs-loader', | |
31 | exclude: /node_modules/, | |
32 | query: { | |
33 | psc: 'psa', | |
2b2207bd | 34 | src: ['bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs'] |
7de41f10 AM |
35 | } |
36 | } | |
37 | // ... | |
38 | ] | |
39 | // ... | |
40 | } | |
41 | ``` | |
42 | ||
44eb153b | 43 | Refer to the [purescript-webpack-example](https://github.com/ethul/purescript-webpack-example) for a more detailed example. |
44 | ||
5163b5a2 AM |
45 | ### Options |
46 | ||
7de41f10 AM |
47 | Default options: |
48 | ||
49 | ```javascript | |
50 | { | |
51 | psc: 'psc', | |
52 | pscArgs: {}, | |
53 | pscBundle: 'psc-bundle', | |
54 | pscBundleArgs: {}, | |
5163b5a2 | 55 | pscIde: false, // instant rebuilds using psc-ide-server (experimental) |
39d11a26 | 56 | pscIdeArgs: {}, // for example, to use different psc-ide-server port: {port: 4088} |
6ab1eca0 | 57 | pscIdeServerArgs: {}, // for example, to change the port { port: 4088 } |
7de41f10 AM |
58 | pscIdeColors: false, // defaults to true if psc === 'psa' |
59 | bundleOutput: 'output/bundle.js', | |
60 | bundleNamespace: 'PS', | |
61 | bundle: false, | |
62 | warnings: true, | |
63 | output: 'output', | |
64 | src: [ | |
65 | path.join('src', '**', '*.purs'), | |
66 | path.join('bower_components', 'purescript-*', 'src', '**', '*.purs') | |
2b2207bd | 67 | ] |
7de41f10 AM |
68 | } |
69 | ``` | |
5163b5a2 AM |
70 | |
71 | ### Instant rebuilds (experimental) | |
72 | ||
73 | Experimental support for instant rebuilds using `psc-ide-server` can be enabled | |
74 | via the `pscIde: true` option. | |
4343e0eb MK |
75 | You can use an already running `psc-ide-server` instance by specifying the port in `pscIdeArgs`, |
76 | if there is no server running this loader will start one for you. | |
77 | ||
78 | ||
79 | #### Slower webpack startup after using purs-loader ? | |
80 | ||
81 | By default, the psc-ide-server will be passed the globs from query.src, this is | |
82 | helpful for other tools using psc-ide-server (for example IDE plugins), however | |
83 | it might result in a slower initial webpack startup time (rebuilds are not | |
84 | affected). To override the default behaviour, add: | |
85 | `pscIdeServerArgs: { "_": ['your/*globs/here'] }` to the loader config | |
86 | ||
87 | ||
88 | ||
89 |