Instantly share code, notes, and snippets.

@svileng /compile
Last active Nov 24, 2016

Embed
What would you like to do?
Elixir LDN Examples
info "Building Phoenix static assets"
npm run build
mix phoenix.digest
plug Plug.Static,
at: "/", from: :my_app, gzip: if(Mix.env == :dev, do: false, else: true),
only: ~w(css fonts images js favicon.ico robots.txt)
{
"name": "app",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "npm run clean:js && npm run webpack",
"webpack": "NODE_ENV=development webpack --color --display-chunks --display-modules",
"build:js": "NODE_ENV=production webpack --color",
"build": "npm run build:js",
"clean:js": "rm -rf priv/static/js/*"
},
"devDependencies": {
"babel-loader": "6.2.4",
"babel-preset-es2015": "6.9.0",
"webpack": "1.13.1"
}
}
var webpack = require("webpack")
var path = require("path")
var dev = process.env.NODE_ENV === "development"
var plugins = [
new webpack.optimize.CommonsChunkPlugin({
children: true,
async: true
})
]
if (!dev) {
plugins = plugins.concat([
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
mangle: true,
compress: {warnings: false}
})
])
}
module.exports = {
devtool: dev ? "eval" : false,
watch: dev,
entry: {
app: path.resolve(__dirname, "web/static/js/app.js")
},
output: {
path: path.resolve(__dirname, "priv/static/js"),
filename: "[name].js",
chunkFilename: dev ? "chunk.[id].js" : "chunk.[id]-[chunkhash].js",
publicPath: "/js/"
},
module: {
loaders: [{
test: /\.js$/,
include: path.resolve(__dirname, "web/static/js"),
loader: "babel",
query: {
cacheDirectory: true,
presets: ["es2015"]
}
}]
},
plugins: plugins
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment