Skip to content

Instantly share code, notes, and snippets.

@weotch
Created June 13, 2018 16:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save weotch/153e5d6ab03b7c9f927e57562e8d2fe7 to your computer and use it in GitHub Desktop.
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