Last active
May 2, 2019 01:52
-
-
Save channainfo/75b8e679340079f0fbb6345158abc2a5 to your computer and use it in GitHub Desktop.
multiple entries js, css in phoenix framework webpack
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 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: { | |
'app': ['./js/app.js'].concat(glob.sync('./vendor/**/*.js')), | |
'frontend': ['./js/frontend.js'].concat(glob.sync('./vendor/**/*.js')), | |
'admin': ['./js/admin.js'].concat(glob.sync('./vendor/**/*.js')), | |
'manage': ['./js/manage.js'].concat(glob.sync('./vendor/**/*.js')) | |
}, | |
output: { | |
filename: '[name].js', | |
path: path.resolve(__dirname, '../priv/static/js') | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
use: { | |
loader: 'babel-loader' | |
} | |
}, | |
{ | |
// test: /\.css$/, | |
// use: [MiniCssExtractPlugin.loader, 'css-loader'] | |
test: /\.scss$/, | |
use: [ | |
MiniCssExtractPlugin.loader, | |
{ | |
loader: 'css-loader', | |
options: {} | |
}, | |
{ | |
loader: 'sass-loader', | |
options: {} | |
} | |
] | |
} | |
] | |
}, | |
plugins: [ | |
// new MiniCssExtractPlugin({ filename: '../css/app.css' }), | |
new MiniCssExtractPlugin({ filename: '../css/[name].css' }), | |
new CopyWebpackPlugin([{ from: 'static/', to: '../' }]) | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment