Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>pull/2186/head
parent
3722099b02
commit
6c9808fe56
@ -0,0 +1,270 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const FileManagerPlugin = require('filemanager-webpack-plugin');
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
const LiveReloadPlugin = require('webpack-livereload-plugin');
|
||||||
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||||
|
const TerserPlugin = require('terser-webpack-plugin');
|
||||||
|
|
||||||
|
module.exports = (env) => {
|
||||||
|
const uiFolder = 'UI';
|
||||||
|
const frontendFolder = path.join(__dirname, '..');
|
||||||
|
const srcFolder = path.join(frontendFolder, 'src');
|
||||||
|
const isProduction = !!env.production;
|
||||||
|
const isProfiling = isProduction && !!env.profile;
|
||||||
|
const inlineWebWorkers = 'no-fallback';
|
||||||
|
|
||||||
|
const distFolder = path.resolve(frontendFolder, '..', '_output', uiFolder);
|
||||||
|
|
||||||
|
console.log('Source Folder:', srcFolder);
|
||||||
|
console.log('Output Folder:', distFolder);
|
||||||
|
console.log('isProduction:', isProduction);
|
||||||
|
console.log('isProfiling:', isProfiling);
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
mode: isProduction ? 'production' : 'development',
|
||||||
|
devtool: isProduction ? 'source-map' : 'eval-source-map',
|
||||||
|
|
||||||
|
stats: {
|
||||||
|
children: false
|
||||||
|
},
|
||||||
|
|
||||||
|
watchOptions: {
|
||||||
|
ignored: /node_modules/
|
||||||
|
},
|
||||||
|
|
||||||
|
entry: {
|
||||||
|
index: 'index.js'
|
||||||
|
},
|
||||||
|
|
||||||
|
resolve: {
|
||||||
|
modules: [
|
||||||
|
srcFolder,
|
||||||
|
path.join(srcFolder, 'Shims'),
|
||||||
|
'node_modules'
|
||||||
|
],
|
||||||
|
alias: {
|
||||||
|
jquery: 'jquery/src/jquery'
|
||||||
|
},
|
||||||
|
fallback: {
|
||||||
|
buffer: false,
|
||||||
|
http: false,
|
||||||
|
https: false,
|
||||||
|
url: false,
|
||||||
|
util: false,
|
||||||
|
net: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
output: {
|
||||||
|
path: distFolder,
|
||||||
|
publicPath: '/',
|
||||||
|
filename: '[name].js',
|
||||||
|
sourceMapFilename: '[file].map'
|
||||||
|
},
|
||||||
|
|
||||||
|
optimization: {
|
||||||
|
moduleIds: 'deterministic',
|
||||||
|
chunkIds: 'named',
|
||||||
|
splitChunks: {
|
||||||
|
chunks: 'initial',
|
||||||
|
name: 'vendors'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
performance: {
|
||||||
|
hints: false
|
||||||
|
},
|
||||||
|
|
||||||
|
plugins: [
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
__DEV__: !isProduction,
|
||||||
|
'process.env.NODE_ENV': isProduction ? JSON.stringify('production') : JSON.stringify('development')
|
||||||
|
}),
|
||||||
|
|
||||||
|
new MiniCssExtractPlugin({
|
||||||
|
filename: 'Content/styles.css'
|
||||||
|
}),
|
||||||
|
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
template: 'frontend/src/index.ejs',
|
||||||
|
filename: 'index.html',
|
||||||
|
publicPath: '/'
|
||||||
|
}),
|
||||||
|
|
||||||
|
new FileManagerPlugin({
|
||||||
|
events: {
|
||||||
|
onEnd: {
|
||||||
|
copy: [
|
||||||
|
// HTML
|
||||||
|
{
|
||||||
|
source: 'frontend/src/*.html',
|
||||||
|
destination: distFolder
|
||||||
|
},
|
||||||
|
|
||||||
|
// Fonts
|
||||||
|
{
|
||||||
|
source: 'frontend/src/Content/Fonts/*.*',
|
||||||
|
destination: path.join(distFolder, 'Content/Fonts')
|
||||||
|
},
|
||||||
|
|
||||||
|
// Icon Images
|
||||||
|
{
|
||||||
|
source: 'frontend/src/Content/Images/Icons/*.*',
|
||||||
|
destination: path.join(distFolder, 'Content/Images/Icons')
|
||||||
|
},
|
||||||
|
|
||||||
|
// Images
|
||||||
|
{
|
||||||
|
source: 'frontend/src/Content/Images/*.*',
|
||||||
|
destination: path.join(distFolder, 'Content/Images')
|
||||||
|
},
|
||||||
|
|
||||||
|
// Robots
|
||||||
|
{
|
||||||
|
source: 'frontend/src/Content/robots.txt',
|
||||||
|
destination: path.join(distFolder, 'Content/robots.txt')
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
new LiveReloadPlugin()
|
||||||
|
],
|
||||||
|
|
||||||
|
resolveLoader: {
|
||||||
|
modules: [
|
||||||
|
'node_modules',
|
||||||
|
'frontend/build/webpack/'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.worker\.js$/,
|
||||||
|
use: {
|
||||||
|
loader: 'worker-loader',
|
||||||
|
options: {
|
||||||
|
filename: '[name].js',
|
||||||
|
inline: inlineWebWorkers
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.js?$/,
|
||||||
|
exclude: /(node_modules|JsLibraries)/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
configFile: `${frontendFolder}/babel.config.js`,
|
||||||
|
envName: isProduction ? 'production' : 'development',
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
modules: false,
|
||||||
|
loose: true,
|
||||||
|
debug: false,
|
||||||
|
useBuiltIns: 'entry',
|
||||||
|
corejs: 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
// CSS Modules
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
exclude: /(node_modules|globals.css)/,
|
||||||
|
use: [
|
||||||
|
{ loader: MiniCssExtractPlugin.loader },
|
||||||
|
{
|
||||||
|
loader: 'css-loader',
|
||||||
|
options: {
|
||||||
|
importLoaders: 1,
|
||||||
|
modules: {
|
||||||
|
localIdentName: '[name]/[local]/[hash:base64:5]'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: 'postcss-loader',
|
||||||
|
options: {
|
||||||
|
postcssOptions: {
|
||||||
|
config: 'frontend/postcss.config.js'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
// Global styles
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
include: /(node_modules|globals.css)/,
|
||||||
|
use: [
|
||||||
|
'style-loader',
|
||||||
|
{
|
||||||
|
loader: 'css-loader'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
// Fonts
|
||||||
|
{
|
||||||
|
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: 'url-loader',
|
||||||
|
options: {
|
||||||
|
limit: 10240,
|
||||||
|
mimetype: 'application/font-woff',
|
||||||
|
emitFile: false,
|
||||||
|
name: 'Content/Fonts/[name].[ext]'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
test: /\.(ttf|eot|eot?#iefix|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: 'file-loader',
|
||||||
|
options: {
|
||||||
|
emitFile: false,
|
||||||
|
name: 'Content/Fonts/[name].[ext]'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isProfiling) {
|
||||||
|
config.resolve.alias['react-dom$'] = 'react-dom/profiling';
|
||||||
|
config.resolve.alias['scheduler/tracing'] = 'scheduler/tracing-profiling';
|
||||||
|
|
||||||
|
config.optimization.minimizer = [
|
||||||
|
new TerserPlugin({
|
||||||
|
cache: true,
|
||||||
|
parallel: true,
|
||||||
|
sourceMap: true, // Must be set to true if using source-maps in production
|
||||||
|
terserOptions: {
|
||||||
|
mangle: false,
|
||||||
|
keep_classnames: true,
|
||||||
|
keep_fnames: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
};
|
@ -1,18 +0,0 @@
|
|||||||
const gulp = require('gulp');
|
|
||||||
|
|
||||||
require('./clean');
|
|
||||||
require('./copy');
|
|
||||||
require('./webpack');
|
|
||||||
|
|
||||||
gulp.task('build',
|
|
||||||
gulp.series('clean',
|
|
||||||
gulp.parallel(
|
|
||||||
'webpack',
|
|
||||||
'copyHtml',
|
|
||||||
'copyFonts',
|
|
||||||
'copyImages',
|
|
||||||
'copyRobots'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
const gulp = require('gulp');
|
|
||||||
const del = require('del');
|
|
||||||
|
|
||||||
const paths = require('./helpers/paths');
|
|
||||||
|
|
||||||
gulp.task('clean', () => {
|
|
||||||
return del([paths.dest.root]);
|
|
||||||
});
|
|
@ -1,42 +0,0 @@
|
|||||||
const path = require('path');
|
|
||||||
const gulp = require('gulp');
|
|
||||||
const print = require('gulp-print').default;
|
|
||||||
const cache = require('gulp-cached');
|
|
||||||
const livereload = require('gulp-livereload');
|
|
||||||
const paths = require('./helpers/paths.js');
|
|
||||||
|
|
||||||
gulp.task('copyHtml', () => {
|
|
||||||
return gulp.src(paths.src.html, { base: paths.src.root })
|
|
||||||
.pipe(cache('copyHtml'))
|
|
||||||
.pipe(print())
|
|
||||||
.pipe(gulp.dest(paths.dest.root))
|
|
||||||
.pipe(livereload());
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('copyFonts', () => {
|
|
||||||
return gulp.src(
|
|
||||||
path.join(paths.src.fonts, '**', '*.*'), { base: paths.src.root }
|
|
||||||
)
|
|
||||||
.pipe(cache('copyFonts'))
|
|
||||||
.pipe(print())
|
|
||||||
.pipe(gulp.dest(paths.dest.root))
|
|
||||||
.pipe(livereload());
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('copyImages', () => {
|
|
||||||
return gulp.src(
|
|
||||||
path.join(paths.src.images, '**', '*.*'), { base: paths.src.root }
|
|
||||||
)
|
|
||||||
.pipe(cache('copyImages'))
|
|
||||||
.pipe(print())
|
|
||||||
.pipe(gulp.dest(paths.dest.root))
|
|
||||||
.pipe(livereload());
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('copyRobots', () => {
|
|
||||||
return gulp.src(paths.src.robots, { base: paths.src.root })
|
|
||||||
.pipe(cache('copyRobots'))
|
|
||||||
.pipe(print())
|
|
||||||
.pipe(gulp.dest(paths.dest.root))
|
|
||||||
.pipe(livereload());
|
|
||||||
});
|
|
@ -1,5 +0,0 @@
|
|||||||
require('./build.js');
|
|
||||||
require('./clean.js');
|
|
||||||
require('./copy.js');
|
|
||||||
require('./watch.js');
|
|
||||||
require('./webpack.js');
|
|
@ -1,6 +0,0 @@
|
|||||||
const colors = require('ansi-colors');
|
|
||||||
|
|
||||||
module.exports = function errorHandler(error) {
|
|
||||||
console.log(colors.red(`Error (${error.plugin}): ${error.message}`));
|
|
||||||
this.emit('end');
|
|
||||||
};
|
|
@ -1,24 +0,0 @@
|
|||||||
const root = './frontend/src';
|
|
||||||
|
|
||||||
const paths = {
|
|
||||||
src: {
|
|
||||||
root,
|
|
||||||
html: `${root}/*.html`,
|
|
||||||
scripts: `${root}/**/*.js`,
|
|
||||||
content: `${root}/Content/`,
|
|
||||||
fonts: `${root}/Content/Fonts/`,
|
|
||||||
images: `${root}/Content/Images/`,
|
|
||||||
robots: `${root}/Content/robots.txt`,
|
|
||||||
exclude: {
|
|
||||||
libs: `!${root}/JsLibraries/**`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
dest: {
|
|
||||||
root: './_output/UI/',
|
|
||||||
content: './_output/UI/Content/',
|
|
||||||
fonts: './_output/UI/Content/Fonts/',
|
|
||||||
images: './_output/UI/Content/Images/'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = paths;
|
|
@ -1,19 +0,0 @@
|
|||||||
const gulp = require('gulp');
|
|
||||||
const livereload = require('gulp-livereload');
|
|
||||||
const gulpWatch = require('gulp-watch');
|
|
||||||
const paths = require('./helpers/paths.js');
|
|
||||||
|
|
||||||
require('./copy.js');
|
|
||||||
require('./webpack.js');
|
|
||||||
|
|
||||||
function watch() {
|
|
||||||
livereload.listen({ start: true });
|
|
||||||
|
|
||||||
gulp.task('webpackWatch')();
|
|
||||||
gulpWatch(paths.src.html, gulp.series('copyHtml'));
|
|
||||||
gulpWatch(`${paths.src.fonts}**/*.*`, gulp.series('copyFonts'));
|
|
||||||
gulpWatch(`${paths.src.images}**/*.*`, gulp.series('copyImages'));
|
|
||||||
gulpWatch(paths.src.robots, gulp.series('copyRobots'));
|
|
||||||
}
|
|
||||||
|
|
||||||
gulp.task('watch', gulp.series('build', watch));
|
|
@ -1,271 +0,0 @@
|
|||||||
const gulp = require('gulp');
|
|
||||||
const webpackStream = require('webpack-stream');
|
|
||||||
const livereload = require('gulp-livereload');
|
|
||||||
const path = require('path');
|
|
||||||
const webpack = require('webpack');
|
|
||||||
const errorHandler = require('./helpers/errorHandler');
|
|
||||||
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
||||||
const HtmlWebpackPluginHtmlTags = require('html-webpack-plugin/lib/html-tags');
|
|
||||||
const TerserPlugin = require('terser-webpack-plugin');
|
|
||||||
|
|
||||||
const uiFolder = 'UI';
|
|
||||||
const frontendFolder = path.join(__dirname, '..');
|
|
||||||
const srcFolder = path.join(frontendFolder, 'src');
|
|
||||||
const isProduction = process.argv.indexOf('--production') > -1;
|
|
||||||
const isProfiling = isProduction && process.argv.indexOf('--profile') > -1;
|
|
||||||
const inlineWebWorkers = 'no-fallback';
|
|
||||||
|
|
||||||
const distFolder = path.resolve(frontendFolder, '..', '_output', uiFolder);
|
|
||||||
|
|
||||||
console.log('Source Folder:', srcFolder);
|
|
||||||
console.log('Output Folder:', distFolder);
|
|
||||||
console.log('isProduction:', isProduction);
|
|
||||||
console.log('isProfiling:', isProfiling);
|
|
||||||
|
|
||||||
const cssVarsFiles = [
|
|
||||||
'../src/Styles/Variables/colors',
|
|
||||||
'../src/Styles/Variables/dimensions',
|
|
||||||
'../src/Styles/Variables/fonts',
|
|
||||||
'../src/Styles/Variables/animations',
|
|
||||||
'../src/Styles/Variables/zIndexes'
|
|
||||||
].map(require.resolve);
|
|
||||||
|
|
||||||
// Override the way HtmlWebpackPlugin injects the scripts
|
|
||||||
// TODO: Find a better way to get these paths without
|
|
||||||
HtmlWebpackPlugin.prototype.injectAssetsIntoHtml = function(html, assets, assetTags) {
|
|
||||||
const head = assetTags.headTags.map((v) => {
|
|
||||||
const href = v.attributes.href
|
|
||||||
.replace('\\', '/')
|
|
||||||
.replace('%5C', '/');
|
|
||||||
|
|
||||||
v.attributes = { rel: 'stylesheet', type: 'text/css', href: `/${href}` };
|
|
||||||
return HtmlWebpackPluginHtmlTags.htmlTagObjectToString(v, this.options.xhtml);
|
|
||||||
});
|
|
||||||
const body = assetTags.bodyTags.map((v) => {
|
|
||||||
v.attributes = { src: `/${v.attributes.src}` };
|
|
||||||
return HtmlWebpackPluginHtmlTags.htmlTagObjectToString(v, this.options.xhtml);
|
|
||||||
});
|
|
||||||
|
|
||||||
return html
|
|
||||||
.replace('<!-- webpack bundles head -->', head.join('\r\n '))
|
|
||||||
.replace('<!-- webpack bundles body -->', body.join('\r\n '));
|
|
||||||
};
|
|
||||||
|
|
||||||
const plugins = [
|
|
||||||
new OptimizeCssAssetsPlugin({}),
|
|
||||||
|
|
||||||
new webpack.DefinePlugin({
|
|
||||||
__DEV__: !isProduction,
|
|
||||||
'process.env.NODE_ENV': isProduction ? JSON.stringify('production') : JSON.stringify('development')
|
|
||||||
}),
|
|
||||||
|
|
||||||
new MiniCssExtractPlugin({
|
|
||||||
filename: path.join('Content', 'styles.css')
|
|
||||||
}),
|
|
||||||
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
template: 'frontend/src/index.html',
|
|
||||||
filename: 'index.html'
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
const config = {
|
|
||||||
mode: isProduction ? 'production' : 'development',
|
|
||||||
devtool: '#source-map',
|
|
||||||
|
|
||||||
stats: {
|
|
||||||
children: false
|
|
||||||
},
|
|
||||||
|
|
||||||
watchOptions: {
|
|
||||||
ignored: /node_modules/
|
|
||||||
},
|
|
||||||
|
|
||||||
entry: {
|
|
||||||
index: 'index.js'
|
|
||||||
},
|
|
||||||
|
|
||||||
resolve: {
|
|
||||||
modules: [
|
|
||||||
srcFolder,
|
|
||||||
path.join(srcFolder, 'Shims'),
|
|
||||||
'node_modules'
|
|
||||||
],
|
|
||||||
alias: {
|
|
||||||
jquery: 'jquery/src/jquery'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
output: {
|
|
||||||
path: distFolder,
|
|
||||||
filename: '[name].js',
|
|
||||||
sourceMapFilename: '[file].map'
|
|
||||||
},
|
|
||||||
|
|
||||||
optimization: {
|
|
||||||
chunkIds: 'named',
|
|
||||||
splitChunks: {
|
|
||||||
chunks: 'initial'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
performance: {
|
|
||||||
hints: false
|
|
||||||
},
|
|
||||||
|
|
||||||
plugins,
|
|
||||||
|
|
||||||
resolveLoader: {
|
|
||||||
modules: [
|
|
||||||
'node_modules',
|
|
||||||
'frontend/gulp/webpack/'
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.worker\.js$/,
|
|
||||||
use: {
|
|
||||||
loader: 'worker-loader',
|
|
||||||
options: {
|
|
||||||
filename: '[name].js',
|
|
||||||
inline: inlineWebWorkers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.js?$/,
|
|
||||||
exclude: /(node_modules|JsLibraries)/,
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: 'babel-loader',
|
|
||||||
options: {
|
|
||||||
configFile: `${frontendFolder}/babel.config.js`,
|
|
||||||
envName: isProduction ? 'production' : 'development',
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
'@babel/preset-env',
|
|
||||||
{
|
|
||||||
modules: false,
|
|
||||||
loose: true,
|
|
||||||
debug: false,
|
|
||||||
useBuiltIns: 'entry',
|
|
||||||
corejs: 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
// CSS Modules
|
|
||||||
{
|
|
||||||
test: /\.css$/,
|
|
||||||
exclude: /(node_modules|globals.css)/,
|
|
||||||
use: [
|
|
||||||
{ loader: MiniCssExtractPlugin.loader },
|
|
||||||
{
|
|
||||||
loader: 'css-loader',
|
|
||||||
options: {
|
|
||||||
importLoaders: 1,
|
|
||||||
modules: {
|
|
||||||
localIdentName: '[name]/[local]/[hash:base64:5]'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: 'postcss-loader',
|
|
||||||
options: {
|
|
||||||
ident: 'postcss',
|
|
||||||
config: {
|
|
||||||
ctx: {
|
|
||||||
cssVarsFiles
|
|
||||||
},
|
|
||||||
path: 'frontend/postcss.config.js'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
// Global styles
|
|
||||||
{
|
|
||||||
test: /\.css$/,
|
|
||||||
include: /(node_modules|globals.css)/,
|
|
||||||
use: [
|
|
||||||
'style-loader',
|
|
||||||
{
|
|
||||||
loader: 'css-loader'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
// Fonts
|
|
||||||
{
|
|
||||||
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: 'url-loader',
|
|
||||||
options: {
|
|
||||||
limit: 10240,
|
|
||||||
mimetype: 'application/font-woff',
|
|
||||||
emitFile: false,
|
|
||||||
name: 'Content/Fonts/[name].[ext]'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
test: /\.(ttf|eot|eot?#iefix|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: 'file-loader',
|
|
||||||
options: {
|
|
||||||
emitFile: false,
|
|
||||||
name: 'Content/Fonts/[name].[ext]'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (isProfiling) {
|
|
||||||
config.resolve.alias['react-dom$'] = 'react-dom/profiling';
|
|
||||||
config.resolve.alias['scheduler/tracing'] = 'scheduler/tracing-profiling';
|
|
||||||
|
|
||||||
config.optimization.minimizer = [
|
|
||||||
new TerserPlugin({
|
|
||||||
cache: true,
|
|
||||||
parallel: true,
|
|
||||||
sourceMap: true, // Must be set to true if using source-maps in production
|
|
||||||
terserOptions: {
|
|
||||||
mangle: false,
|
|
||||||
keep_classnames: true,
|
|
||||||
keep_fnames: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
gulp.task('webpack', () => {
|
|
||||||
return webpackStream(config)
|
|
||||||
.pipe(gulp.dest('_output/UI'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('webpackWatch', () => {
|
|
||||||
config.watch = true;
|
|
||||||
|
|
||||||
return webpackStream(config, webpack)
|
|
||||||
.on('error', errorHandler)
|
|
||||||
.pipe(gulp.dest('_output/UI'))
|
|
||||||
.on('error', errorHandler)
|
|
||||||
.pipe(livereload())
|
|
||||||
.on('error', errorHandler);
|
|
||||||
});
|
|
@ -1,23 +1,32 @@
|
|||||||
const reload = require('require-nocache')(module);
|
const reload = require('require-nocache')(module);
|
||||||
|
|
||||||
module.exports = (ctx, configPath, options) => {
|
const cssVarsFiles = [
|
||||||
const config = {
|
'./src/Styles/Variables/colors',
|
||||||
plugins: {
|
'./src/Styles/Variables/dimensions',
|
||||||
'postcss-mixins': {
|
'./src/Styles/Variables/fonts',
|
||||||
mixinsDir: [
|
'./src/Styles/Variables/animations',
|
||||||
'frontend/src/Styles/Mixins'
|
'./src/Styles/Variables/zIndexes'
|
||||||
]
|
].map(require.resolve);
|
||||||
},
|
|
||||||
'postcss-simple-vars': {
|
|
||||||
variables: () =>
|
|
||||||
ctx.options.cssVarsFiles.reduce((acc, vars) => {
|
|
||||||
return Object.assign(acc, reload(vars));
|
|
||||||
}, {})
|
|
||||||
},
|
|
||||||
'postcss-color-function': {},
|
|
||||||
'postcss-nested': {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return config;
|
const mixinsFiles = [
|
||||||
|
'frontend/src/Styles/Mixins/cover.css',
|
||||||
|
'frontend/src/Styles/Mixins/linkOverlay.css',
|
||||||
|
'frontend/src/Styles/Mixins/scroller.css',
|
||||||
|
'frontend/src/Styles/Mixins/truncate.css'
|
||||||
|
];
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
plugins: [
|
||||||
|
['postcss-mixins', {
|
||||||
|
mixinsFiles
|
||||||
|
}],
|
||||||
|
['postcss-simple-vars', {
|
||||||
|
variables: () =>
|
||||||
|
cssVarsFiles.reduce((acc, vars) => {
|
||||||
|
return Object.assign(acc, reload(vars));
|
||||||
|
}, {})
|
||||||
|
}],
|
||||||
|
'postcss-color-function',
|
||||||
|
'postcss-nested'
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in new issue