GridFieldBulkEditingTools/webpack.config.js
Robbie Averill 148d5efcea Update webpack implementation and refactor JS to remove lint warnings (#179)
* Update webpack-config to more closely align with SilverStripe core modules

* Automated linting

* Remove all JS linting errors, use let/const for assignment, do not reassign callback arguments

* Rebuild dist files, remove yarn lock from build command, remove source map files
2018-08-16 15:45:17 +03:00

62 lines
1.6 KiB
JavaScript

const Path = require('path');
const webpack = require('webpack');
// Import the core config
const webpackConfig = require('@silverstripe/webpack-config');
const {
resolveJS,
externalJS,
moduleJS,
pluginJS,
moduleCSS,
pluginCSS,
} = webpackConfig;
const ENV = process.env.NODE_ENV;
const PATHS = {
// the root path, where your webpack.config.js is located.
ROOT: Path.resolve(),
// your node_modules folder name, or full path
MODULES: 'node_modules',
// relative path from your css files to your other files, such as images and fonts
FILES_PATH: '../',
// the root path to your javascript source files
SRC: Path.resolve('client/src'),
DIST: Path.resolve('client/dist'),
};
const config = [
{
name: 'js',
entry: {
main: `${PATHS.SRC}/bundles/bundle.js`,
},
output: {
path: PATHS.DIST,
filename: 'js/[name].js',
},
devtool: (ENV !== 'production') ? 'source-map' : '',
resolve: resolveJS(ENV, PATHS),
externals: externalJS(ENV, PATHS),
module: moduleJS(ENV, PATHS),
plugins: pluginJS(ENV, PATHS),
},
{
name: 'css',
entry: {
main: `${PATHS.SRC}/styles/bundle.scss`,
},
output: {
path: PATHS.DIST,
filename: 'styles/[name].css'
},
devtool: (ENV !== 'production') ? 'source-map' : '',
module: moduleCSS(ENV, PATHS),
plugins: pluginCSS(ENV, PATHS),
},
];
// Use WEBPACK_CHILD=js or WEBPACK_CHILD=css env var to run a single config
module.exports = (process.env.WEBPACK_CHILD)
? config.find((entry) => entry.name === process.env.WEBPACK_CHILD)
: module.exports = config;