|
|
|
const path = require("path")
|
|
|
|
const webpack = require("webpack")
|
|
|
|
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
|
|
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts')
|
|
|
|
const CopyPlugin = require("copy-webpack-plugin");
|
|
|
|
|
|
|
|
const mode = process.env.NODE_ENV === 'development' ? 'development' : 'production'
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
mode,
|
|
|
|
devtool: "source-map",
|
|
|
|
entry: {
|
|
|
|
application: [
|
|
|
|
"./app/frontend/application.js",
|
|
|
|
],
|
|
|
|
active_admin: [
|
|
|
|
'./app/frontend/active_admin.js',
|
|
|
|
'./app/frontend/styles/active_admin.scss'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.modernizrrc.js$/,
|
|
|
|
use: ['@sect/modernizr-loader']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.modernizrrc(\.json)?$/,
|
|
|
|
use: [
|
|
|
|
'@sect/modernizr-loader','json-loader'
|
|
|
|
],
|
|
|
|
type: 'javascript/auto'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(js|ts)$/,
|
|
|
|
include: [/node_modules/, /frontend/],
|
|
|
|
use: ['babel-loader'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpe?g|gif|eot|woff2|woff|ttf|svg|ico)$/i,
|
|
|
|
use: 'file-loader',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(scss|css)/i,
|
|
|
|
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
|
|
|
|
}
|
|
|
|
],
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
modules: ['node_modules', 'node_modules/govuk-frontend/govuk'],
|
|
|
|
alias: {
|
|
|
|
// You can add comment "Please do not delete this file" in this file
|
|
|
|
modernizr$: path.resolve(__dirname, ".modernizrrc")
|
|
|
|
}
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: "[name].js",
|
|
|
|
path: path.resolve(__dirname, "app/assets/builds"),
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new RemoveEmptyScriptsPlugin(),
|
|
|
|
new MiniCssExtractPlugin(),
|
|
|
|
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
|
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{ from: "node_modules/govuk-frontend/govuk/assets/images", to: "images" },
|
|
|
|
{ from: "node_modules/govuk-frontend/govuk/assets/fonts", to: "fonts" },
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
$: 'jquery',
|
|
|
|
jQuery: 'jquery',
|
|
|
|
jquery: 'jquery',
|
|
|
|
'window.jQuery': 'jquery'
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}
|