161 lines
4.0 KiB
JavaScript
Raw Normal View History

2017-01-17 13:40:59 +01:00
/**
* WEBPACK DLL GENERATOR
*
2018-10-04 15:22:10 -05:00
* This profile is used to cache webpack's module contexts for external library and framework type dependencies which
* will usually not change often enough to warrant building them from scratch every time we use the webpack process.
2017-01-17 13:40:59 +01:00
*/
const path = require('path');
2017-01-17 13:40:59 +01:00
const webpack = require('webpack');
const isAdmin = process.env.IS_ADMIN === 'true';
const isSetup = process.env.IS_MONOREPO || false;
2018-12-06 19:00:49 +01:00
const appPath = process.env.APP_PATH || path.resolve(process.env.PWD, '..', isAdmin ? '' : '..');
const rootAdminpath = (() => {
if (isSetup) {
2018-12-06 19:00:49 +01:00
return isAdmin
? path.resolve(appPath, 'strapi-admin')
: path.resolve(appPath, 'packages', 'strapi-admin');
}
return path.resolve(appPath, 'admin');
})();
2017-01-17 13:40:59 +01:00
module.exports = {
context: appPath,
entry: {
2018-12-06 19:00:49 +01:00
vendor: [
'react',
'react-dom',
'react-intl',
'reactstrap',
'react-transition-group',
'immutable',
'lodash',
'babel-polyfill',
], // Shared dependencies accross the admin and plugins.
},
devtool: 'cheap-module-source-map',
2017-01-17 13:40:59 +01:00
output: {
filename: '[name].dll.js',
2018-12-06 19:00:49 +01:00
path: path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'lib',
'internals',
'webpack',
'dist',
),
// The name of the global variable which the library's
// require() function will be assigned to
library: '[name]_lib',
2017-01-17 13:40:59 +01:00
},
plugins: [
new webpack.DllPlugin({
name: '[name]_lib',
path: path.resolve(rootAdminpath, 'admin', 'src', 'config', 'manifest.json'),
}),
2017-01-17 13:40:59 +01:00
],
2017-05-16 16:32:54 +02:00
resolve: {
modules: [
'admin/src',
'node_modules/strapi-helper-plugin/lib/src',
'node_modules/strapi-helper-plugin/node_modules',
'node_modules',
],
alias: {
moment: 'moment/moment.js',
2018-12-06 19:00:49 +01:00
'babel-polyfill': path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'node_modules',
'babel-polyfill',
),
lodash: path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'node_modules',
'lodash',
),
immutable: path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'node_modules',
'immutable',
),
'react-intl': path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'node_modules',
'react-intl',
),
react: path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'node_modules',
'react',
),
'react-dom': path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'node_modules',
'react-dom',
),
'react-transition-group': path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'node_modules',
'react-transition-group',
),
reactstrap: path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'node_modules',
'reactstrap',
),
'react-dnd': path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'node_modules',
'react-dnd',
),
'react-dnd-hmtl5-backend': path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'node_modules',
'react-dnd-html5-backend',
),
'styled-components': path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'node_modules',
'styled-components',
),
'react-copy-to-clipboard': path.resolve(
rootAdminpath,
'node_modules',
'strapi-helper-plugin',
'node_modules',
'react-copy-to-clipboard',
),
},
symlinks: false,
2018-12-06 19:00:49 +01:00
extensions: ['.js', '.jsx', '.react.js'],
mainFields: ['browser', 'jsnext:main', 'main'],
2017-05-16 16:32:54 +02:00
},
2017-01-17 13:40:59 +01:00
};