Skip to content

Instantly share code, notes, and snippets.

@martdn
Created April 9, 2019 12:52
Show Gist options
  • Save martdn/3aef178976590feeaf080cba4abb8b6d to your computer and use it in GitHub Desktop.
Save martdn/3aef178976590feeaf080cba4abb8b6d to your computer and use it in GitHub Desktop.
const path = require('path');
const webpack = require('webpack');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: {
main: './src/features/main/index.js',
admin: './src/features/admin/index.js'
},
output: {
filename: '[name].entry.js',
path: path.resolve(__dirname, 'public/dist')
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "eslint-loader"
},
{
test: /\.css$/,
exclude: /node_modules/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
'css-loader',
'postcss-loader'
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].css"
}),
new CleanWebpackPlugin(),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/g,
cssProcessor: require('cssnano'),
cssProcessorPluginOptions: {
preset: ['default', { discardComments: { removeAll: true } }]
},
canPrint: true
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}),
new BrowserSyncPlugin({
proxy: 'localhost:8000',
host: 'localhost',
port: 3000,
files: ['./src/*'],
injectChanges: true
})
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment