* fix: remove circular dependency redux depended on templates/Challenges/redux and vice versa. This meant that import order mattered and confusing bugs could arise. (cherry picked from commit 7d67a4e70922bbb3051f2f9982dcc69e240d43dc) * feat: require imports to be in alphabetical order Import order generally does not matter, but there are edge cases (circular imports and css imports, for example) where changing order changes behaviour (cherry picked from commit b8d1393a91ec6e068caf8e8498a5c95df68c2b2c) * chore: order imports * fix: lift up challenge description + title comps This brings the classic Show closer to the others as they now all create the description and title components * fix: remove donation-saga/index circular import (cherry picked from commit 51a44ca668a700786d2744feffeae4fdba5fd207) * refactor: extract action-types from settings (cherry picked from commit 25e26124d691c84a0d0827d41dafb761c686fadd) * fix: lint errors * feat: prevent useless renames
85 lines
2.4 KiB
JavaScript
85 lines
2.4 KiB
JavaScript
const { writeFileSync } = require('fs');
|
|
const path = require('path');
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
const webpack = require('webpack');
|
|
|
|
module.exports = (env = {}) => {
|
|
const __DEV__ = env.production !== true;
|
|
const staticPath = path.join(__dirname, './static/js');
|
|
const configPath = path.join(__dirname, '../config/client');
|
|
return {
|
|
cache: __DEV__ ? { type: 'filesystem' } : false,
|
|
mode: __DEV__ ? 'development' : 'production',
|
|
entry: {
|
|
'frame-runner': './src/client/frame-runner.js',
|
|
'sass-compile': './src/client/workers/sass-compile.js',
|
|
'test-evaluator': './src/client/workers/test-evaluator.js'
|
|
},
|
|
devtool: __DEV__ ? 'inline-source-map' : 'source-map',
|
|
output: {
|
|
publicPath: '/js/',
|
|
filename: chunkData => {
|
|
// construct and output the filename here, so the client can use the
|
|
// json to find the file.
|
|
const filename = `${chunkData.chunk.name}.${chunkData.chunk.contentHash.javascript}`;
|
|
writeFileSync(
|
|
path.join(configPath, `${chunkData.chunk.name}.json`),
|
|
`{"filename": "${filename}"}`
|
|
);
|
|
return filename + '.js';
|
|
},
|
|
chunkFilename: '[name].[contenthash].js',
|
|
path: staticPath
|
|
},
|
|
stats: {
|
|
// Display bailout reasons
|
|
optimizationBailout: true
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.(js|ts)$/,
|
|
exclude: /node_modules/,
|
|
use: {
|
|
loader: 'babel-loader',
|
|
options: {
|
|
babelrc: false,
|
|
presets: [
|
|
[
|
|
'@babel/preset-env',
|
|
{ modules: false, targets: '> 0.25%, not dead' }
|
|
],
|
|
'@babel/preset-typescript'
|
|
],
|
|
plugins: [
|
|
'@babel/plugin-transform-runtime',
|
|
'@babel/plugin-syntax-dynamic-import'
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new CopyWebpackPlugin({
|
|
patterns: ['node_modules/sass.js/dist/sass.sync.js']
|
|
}),
|
|
new webpack.ProvidePlugin({
|
|
process: 'process/browser'
|
|
}),
|
|
new webpack.ProvidePlugin({
|
|
Buffer: ['buffer', 'Buffer']
|
|
})
|
|
],
|
|
resolve: {
|
|
fallback: {
|
|
buffer: require.resolve('buffer'),
|
|
util: false,
|
|
stream: false,
|
|
process: require.resolve('process/browser')
|
|
},
|
|
extensions: ['.js', '.ts']
|
|
}
|
|
};
|
|
};
|