76 lines
2.0 KiB
JavaScript
76 lines
2.0 KiB
JavaScript
const path = require('path');
|
|
const glob = require('glob');
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
const webpack = require('webpack');
|
|
|
|
module.exports = (env, options) => {
|
|
// const devMode = options.mode !== 'production';
|
|
const devMode = true;
|
|
|
|
return {
|
|
optimization: {
|
|
minimizer: [
|
|
new TerserPlugin({ cache: true, parallel: true, sourceMap: devMode }),
|
|
new OptimizeCSSAssetsPlugin({})
|
|
]
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
foundation: path.resolve(__dirname, 'node_modules/foundation-sites/scss/')
|
|
}
|
|
},
|
|
entry: {
|
|
'app': './js/app.js',
|
|
'foundation': './js/foundation.js',
|
|
'aesthetics': './css/aesthetics.scss',
|
|
'sw': './js/sw.js',
|
|
},
|
|
output: {
|
|
filename: '[name].js',
|
|
path: path.resolve(__dirname, '../priv/static/js'),
|
|
publicPath: '/js/'
|
|
},
|
|
devtool: devMode ? 'source-map' : undefined,
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.js$/,
|
|
exclude: /node_modules/,
|
|
use: {
|
|
loader: 'babel-loader'
|
|
}
|
|
},
|
|
{
|
|
test: /\.(sa|sc|c)ss$/,
|
|
use: [
|
|
{
|
|
loader: MiniCssExtractPlugin.loader,
|
|
options: {
|
|
hmr: process.env.NODE_ENV === 'development',
|
|
publicPath: '../css/',
|
|
},
|
|
},
|
|
'css-loader',
|
|
'sass-loader',
|
|
],
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new MiniCssExtractPlugin({
|
|
filename: '../css/[name].css',
|
|
chunkFilename: '../css/[id].css',
|
|
}),
|
|
new CopyWebpackPlugin([{ from: 'static/', to: '../' }]),
|
|
new webpack.ProvidePlugin({
|
|
$: "jquery",
|
|
jQuery: "jquery",
|
|
"window.jQuery": "jquery"
|
|
}),
|
|
]
|
|
}
|
|
};
|