Files
frontend-app-profile/webpack/webpack.dev.config.js
David Joy 5ac0558a92 Use frontend-base! (#220)
* Adding frontend-builder and frontend-core stubs

* gatsby stub added

* Remove gatsby stuff.

* Reorganization of top level app.

Some naming TBD.

* Review feedback.

* Various config improvements

- Adding APP_ERROR handler for top level errors.
- Splitting footer config out of main app config.
- Simplifying config variables and deriving some from others in the files that need them.

* Use App.error()

* Improving exports/imports from frontend-core

* Moving header and footer out of src.

Getting rid of “common”

* Setting authentication directlty from App.authentication in AppProvider.

* Switching over to using frontend-base.

Updating a bunch of dependencies to their latest versions in the process.

* Bumping versions of frontend-base and frontend-auth

* Getting tests working again.

* Addressing review feedback and bumping to a newer version of frontend-base.

* Removing unneeded eslint disable lines.

* Updating usage of frontend-logging to remove deprecated method names.

* Bumping node-sass version to 4.12.0 - hopefully fixes node 12 build

* css-loader now requires cssnano for minification

* fix: couldn’t set preferred language visibility.
2019-09-16 16:49:16 -04:00

171 lines
6.2 KiB
JavaScript
Executable File

// This is the dev Webpack config. All settings here should prefer a fast build
// time at the expense of creating larger, unoptimized bundles.
const Merge = require('webpack-merge');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const PostCssRtlPlugin = require('postcss-rtl');
const commonConfig = require('./webpack.common.config.js');
module.exports = Merge.smart(commonConfig, {
mode: 'development',
devtool: 'eval-source-map',
entry: {
// enable react's custom hot dev client so we get errors reported in the browser
hot: require.resolve('react-dev-utils/webpackHotDevClient'),
app: path.resolve(__dirname, '../src/index.jsx'),
},
module: {
// Specify file-by-file rules to Webpack. Some file-types need a particular kind of loader.
rules: [
// The babel-loader transforms newer ES2015+ syntax to older ES5 for older browsers.
// Babel is configured with the .babelrc file at the root of the project.
{
test: /\.(js|jsx)$/,
include: [
path.resolve(__dirname, '../src'),
path.resolve(__dirname, '../footer'),
path.resolve(__dirname, '../header'),
],
loader: 'babel-loader',
options: {
// Caches result of loader to the filesystem. Future builds will attempt to read from the
// cache to avoid needing to run the expensive recompilation process on each run.
cacheDirectory: true,
},
},
// We are not extracting CSS from the javascript bundles in development because extracting
// prevents hot-reloading from working, it increases build time, and we don't care about
// flash-of-unstyled-content issues in development.
{
test: /(.scss|.css)$/,
use: [
'style-loader', // creates style nodes from JS strings
{
loader: 'css-loader', // translates CSS into CommonJS
options: {
sourceMap: true,
},
},
{
loader: 'postcss-loader',
options: {
plugins: () => [PostCssRtlPlugin()],
},
},
{
loader: 'sass-loader', // compiles Sass to CSS
options: {
sourceMap: true,
includePaths: [
path.join(__dirname, '../node_modules'),
path.join(__dirname, '../src'),
],
},
},
],
},
{
test: /.svg$/,
issuer: {
test: /\.jsx?$/,
},
loader: '@svgr/webpack',
},
// Webpack, by default, uses the url-loader for images and fonts that are required/included by
// files it processes, which just base64 encodes them and inlines them in the javascript
// bundles. This makes the javascript bundles ginormous and defeats caching so we will use the
// file-loader instead to copy the files directly to the output directory.
{
test: /\.(woff2?|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader',
},
{
test: /\.(jpe?g|png|gif|ico)(\?v=\d+\.\d+\.\d+)?$/,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
optimizationlevel: 7,
mozjpeg: {
progressive: true,
},
gifsicle: {
interlaced: false,
},
pngquant: {
quality: '65-90',
speed: 4,
},
},
},
],
},
],
},
// Specify additional processing or side-effects done on the Webpack output bundles as a whole.
plugins: [
// Generates an HTML file in the output directory.
new HtmlWebpackPlugin({
inject: true, // Appends script tags linking to the webpack bundles at the end of the body
template: path.resolve(__dirname, '../public/index.html'),
}),
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
// App configuration
ACCESS_TOKEN_COOKIE_NAME: 'edx-jwt-cookie-header-payload',
BASE_URL: 'localhost:1995',
CREDENTIALS_BASE_URL: 'http://localhost:18150',
CSRF_COOKIE_NAME: 'csrftoken',
CSRF_TOKEN_API_PATH: '/csrf/api/v1/token',
ECOMMERCE_BASE_URL: 'http://localhost:18130',
LANGUAGE_PREFERENCE_COOKIE_NAME: 'openedx-language-preference',
LMS_BASE_URL: 'http://localhost:18000',
LOGIN_URL: 'http://localhost:18000/login',
LOGOUT_URL: 'http://localhost:18000/login',
MARKETING_SITE_BASE_URL: 'http://localhost:18000',
ORDER_HISTORY_URL: 'localhost:1996/orders',
REFRESH_ACCESS_TOKEN_ENDPOINT: 'http://localhost:18000/login_refresh',
SEGMENT_KEY: null,
SITE_NAME: 'edX',
USER_INFO_COOKIE_NAME: 'edx-user-info',
// ProfileFooter configuration
APPLE_APP_STORE_URL: 'https://www.apple.com/ios/app-store/',
CONTACT_URL: 'http://localhost:18000/contact',
ENTERPRISE_MARKETING_FOOTER_UTM_MEDIUM: 'Footer',
ENTERPRISE_MARKETING_URL: 'http://example.com',
ENTERPRISE_MARKETING_UTM_CAMPAIGN: 'my_campaign',
ENTERPRISE_MARKETING_UTM_SOURCE: 'edX profile',
FACEBOOK_URL: 'https://www.facebook.com',
GOOGLE_PLAY_URL: 'https://play.google.com/store',
LINKED_IN_URL: 'https://www.linkedin.com',
OPEN_SOURCE_URL: 'http://localhost:18000/openedx',
PRIVACY_POLICY_URL: 'http://localhost:18000/privacy-policy',
REDDIT_URL: 'https://www.reddit.com',
SUPPORT_URL: 'http://localhost:18000/support',
TERMS_OF_SERVICE_URL: 'http://localhost:18000/terms-of-service',
TWITTER_URL: 'https://twitter.com',
YOU_TUBE_URL: 'https://www.youtube.com',
}),
// when the --hot option is not passed in as part of the command
// the HotModuleReplacementPlugin has to be specified in the Webpack configuration
// https://webpack.js.org/configuration/dev-server/#devserver-hot
new webpack.HotModuleReplacementPlugin(),
],
// This configures webpack-dev-server which serves bundles from memory and provides live
// reloading.
devServer: {
host: '0.0.0.0',
port: 1995,
historyApiFallback: true,
hot: true,
inline: true,
publicPath: '/',
},
});