/* eslint-disable func-names, no-useless-escape, object-shorthand */
// webpack plugins
const ExtractTextPlugin = require('extract-text-webpack-plugin');
// Get paths.
const paths = require('../core/paths');
const baseConfig = {
// These modules will be loaded outside of webpack e.g. via a CDN.
externals: {
jquery: 'jQuery',
},
// Define which loaders will be used for different file extensions.
module: {
rules: [{
test: /\.html$/,
use: [
// Use the html-loader to parse and minify HTML imports.
'html-loader',
],
},
{
test: /\.js$/,
use: [{
// Use the eslint-loader to validate the JS files before bundling.
loader: 'eslint-loader',
options: {
ignorePath: paths.eslintIgnore
},
}, ],
enforce: 'pre',
include: [paths.js],
exclude: [paths.vendor],
},
{
test: /\.js$/,
use: [{
// Use the babel-loader to transpile the JS to browser-compatible syntax.
loader: 'babel-loader',
}],
include: [paths.js],
exclude: [paths.vendor],
},
{
test: /\.(css|scss)$/,
// Use the ExtractTextPlugin to move CSS to a separate file.
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [{
// Use the css-loader to parse and minify CSS imports.
// N.B Sourcemaps enabled, but wont be output if devtool setting is commented out
loader: 'css-loader',
options: {
autoprefixer: false,
sourceMap: true
},
},
{
// Use the postcss-loader to add vendor prefixes via autoprefixer.
// N.B Sourcemaps enabled, but wont be output if devtool setting is commented out
loader: 'postcss-loader',
options: {
config: {
path: paths.postcssConfig
},
sourceMap: true
},
},
{
// Use the sass-loader to parse and minify CSS imports.
// N.B Sourcemaps enabled, but wont be output if devtool setting is commented out
loader: 'sass-loader?sourceMap',
options: {
sourceMap: true
},
},
],
publicPath: paths.mvcAppPath + '/sitefiles/dist/',
}),
},
{
test: /loadcss\.js$/,
use: [
// Shim fg-loadcss to access the window object.
'imports-loader?exports=>undefined',
'exports-loader?window.loadCSS',
],
exclude: [paths.js],
include: /fg-loadcss/,
},
{
test: /cssrelpreload\.js$/,
use: [
// Shim fg-loadcss to access the window object.
'imports-loader?this=>window',
],
exclude: [paths.js],
include: /fg-loadcss/,
},
{
test: /waypoints\.js$/,
use: [
// Shim waypoints to access the window object.
'exports-loader?window.Waypoint',
],
exclude: [paths.js],
include: /waypoints/,
},
{
test: /\.js$/,
use: [
// Shim videojs to force correct module syntax.
'imports-loader?this=>window&exports=>false&define=>false',
],
exclude: [paths.js],
include: /video\.js/,
},
{
test: /\.js$/,
use: [
// Shim videojs to force correct module syntax.
'imports-loader?this=>window&exports=>false&define=>false',
],
exclude: [paths.js],
include: /videojs-youtube/,
},
],
noParse: [
// Ignore prebuilt warning for videojs
/[\/\\]video\.js$/,
/[\/\\]video\.min\.js$/,
/[\/\\]videojs-youtube/,
],
},
resolve: {
alias: {
// Add aliases for common source folders.
fonts: paths.fonts,
img: paths.img,
js: paths.js,
sass: paths.sass,
vendor: paths.vendor,
// Add aliases for vendor modules.
'loadcss-core': 'fg-loadcss/src/loadcss',
'loadcss-polyfill': 'fg-loadcss/src/cssrelpreload',
'videojs-core': 'video.js/dist/video.js',
'videojs-youtube': 'videojs-youtube/dist/Youtube',
'waypoints-core': 'waypoints/lib/jquery.waypoints.js',
'waypoints-infinite': 'waypoints/lib/shortcuts/infinite.js',
'waypoints-inview': 'waypoints/lib/shortcuts/inview.js',
'waypoints-sticky': 'waypoints/lib/shortcuts/sticky.js',
},
},
};
module.exports = baseConfig;