Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example Decoy custom js/css webpack build config
###
Generate customized Decoy assets
###
# Deps
ExtractText = require 'extract-text-webpack-plugin'
autoprefixer = require 'autoprefixer'
webpack = require 'webpack'
# Autoprefixer config
# https://github.com/ai/browserslist#queries
autoprefixer = autoprefixer browsers: [
'last 2 versions'
'ie >= 9'
]
# Webpack config
module.exports =
# Entry point for admin
entry: admin: './resources/assets/admin/index.coffee'
# Where to put the admin assets
output:
path: __dirname + '/public/dist/'
publicPath: '/dist/'
filename: '[name].min.js'
# Assist in forming paths
resolve: alias: '~~': __dirname
# Loaders
module: rules: [
{
test: /\.coffee$/
loader: 'babel-loader!coffee-loader'
}
{
test: /\.css$/
use: ExtractText.extract use: [
{
loader: 'css-loader'
options:
sourceMap: false
minimize: true
}
{
loader: 'postcss-loader'
options:
sourceMap: false
plugins: (loader) -> [ autoprefixer ]
}
]
}
{
test: /\.styl$/,
use: ExtractText.extract use: [
{
loader: 'css-loader'
options:
sourceMap: false
minimize: true
}
{
loader: 'postcss-loader'
options:
sourceMap: false
plugins: (loader) -> [ autoprefixer ]
}
{
loader: 'stylus-loader'
options:
sourceMap: false
preferPathResolver: 'webpack' # Faster
}
]
}
]
# Webpack plugins
plugins: [
new webpack.optimize.UglifyJsPlugin compress: warnings: false
new ExtractText
filename: '[name].min.css'
allChunks: true
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment