Last active
October 14, 2019 18:55
-
-
Save Risto-Stevcev/fb3680a2e676d0e8b684a92723269f93 to your computer and use it in GitHub Desktop.
Tree shaking only for bs-declaredom
This file contains hidden or 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
let _ = Js.log "hello world!" | |
let x = | |
let open RistostevcevBsDeclaredom.Html in | |
div [|text "foobar"|] | |
let _ = | |
if Js.Option.isSome HotModuleReload.module_hot then | |
let _ = HotModuleReload.on_accept @@ fun () -> Js.log "accept: reloading..." | |
and _ = HotModuleReload.on_dispose @@ fun () -> Js.log "dispose: reloading..." | |
in () |
This file contains hidden or 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
const path = require('path'); | |
const dir_js = path.resolve(__dirname, 'lib/es6_global/src/'); | |
const dir_build = path.resolve(__dirname, 'dist'); | |
/** | |
This tree shakes reasonably well, but it would be nice to get code-splitting working with bs-declaredom so | |
that the browser can cache the declaredom stuff: | |
```sh | |
Built at: 10/12/2019 12:55:49 PM | |
Asset Size Chunks Chunk Names | |
bundle.webpack.js 47.2 KiB 0 [emitted] main | |
bundle.webpack.js.map 800 KiB 0 [emitted] [dev] main | |
``` | |
**/ | |
module.exports = { | |
entry: path.resolve(dir_js, 'Frontend.bs.js'), | |
output: { | |
path: dir_build, | |
filename: 'bundle.webpack.js' | |
}, | |
devServer: { | |
contentBase: dir_build, | |
}, | |
module: { | |
rules: [ | |
{ | |
sideEffects: false, | |
test: /\.m?js$/, | |
exclude: /(node_modules|bower_components)/, | |
use: { | |
loader: 'babel-loader', | |
options: { | |
presets: ['@babel/preset-env'], | |
plugins: ['@babel/plugin-proposal-object-rest-spread'] | |
} | |
} | |
} | |
] | |
}, | |
stats: { | |
// Nice colored output | |
colors: true | |
}, | |
mode: 'production', | |
// Create source maps for the bundle | |
devtool: 'source-map', | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment