Created
March 3, 2020 02:31
-
-
Save jfreeze/04407216a596351163af7e11b56d278a to your computer and use it in GitHub Desktop.
This file contains 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 glob = require('glob'); | |
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | |
const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); | |
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); | |
const CopyWebpackPlugin = require('copy-webpack-plugin'); | |
module.exports = (env, options) => ({ | |
optimization: { | |
minimizer: [ | |
new UglifyJsPlugin({ cache: true, parallel: true, sourceMap: false }), | |
new OptimizeCSSAssetsPlugin({}) | |
] | |
}, | |
entry: { | |
'./js/app.js': ['./js/app.js'].concat(glob.sync('./vendor/**/*.js')) | |
}, | |
output: { | |
filename: 'app.js', | |
path: path.resolve(__dirname, '../priv/static/js') | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
use: { | |
loader: 'babel-loader' | |
} | |
}, | |
{ | |
test: /\.css$/, | |
exclude: /node_modules/, | |
use: [ | |
{ loader: 'style-loader', }, | |
{ loader: MiniCssExtractPlugin.loader }, | |
{ loader: 'css-loader', options: { importLoaders: 1, url: false } }, | |
{ loader: 'postcss-loader' }, | |
] | |
}, | |
] | |
}, | |
plugins: [ | |
new MiniCssExtractPlugin({ filename: '../css/app.css' }), // path relative to output path above: priv/static/js | |
new CopyWebpackPlugin([{ from: 'static/', to: '../' }]) | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment