2018-01-12 06:41:02 -05:00
|
|
|
const path = require('path')
|
|
|
|
|
|
|
|
module.exports = {
|
2018-01-12 07:34:04 -05:00
|
|
|
// Defines the "entry point(s)" for the application - i.e. the file which
|
2018-01-12 06:41:02 -05:00
|
|
|
// bootstraps the application
|
|
|
|
entry: {
|
2018-01-16 12:51:30 -05:00
|
|
|
richText: './public/es/rich-text.js'
|
2018-01-12 06:41:02 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
// Define where and how the bundle will be output to disk
|
|
|
|
// Note: webpack-dev-server does not write the bundle to disk, instead it is
|
|
|
|
// kept in memory for speed
|
|
|
|
output: {
|
2018-01-12 07:34:04 -05:00
|
|
|
path: path.join(__dirname, '/public/js/es'),
|
2018-01-12 06:41:02 -05:00
|
|
|
|
|
|
|
filename: '[name].js',
|
|
|
|
|
|
|
|
// Output as UMD bundle (allows main JS to import with CJS, AMD or global
|
|
|
|
// style code bundles
|
|
|
|
libraryTarget: 'umd',
|
|
|
|
// Name the exported variable from output bundle
|
|
|
|
library: ['Frontend', '[name]']
|
|
|
|
},
|
|
|
|
|
|
|
|
// TODO??
|
|
|
|
// Defines the external modules which will be stripped out when bundling for
|
2018-01-12 07:34:04 -05:00
|
|
|
// the main app. These modules are already loaded in the main app environment,
|
|
|
|
// so we strip them out to prevent conflicts.
|
2018-01-12 06:41:02 -05:00
|
|
|
// externals: {},
|
|
|
|
|
|
|
|
// Define how file types are handled by webpack
|
|
|
|
module: {
|
|
|
|
rules: [{
|
|
|
|
// Pass application JS files through babel-loader, compiling to ES5
|
2018-02-22 14:27:25 -05:00
|
|
|
test: /\.js$/,
|
2018-01-12 06:41:02 -05:00
|
|
|
// Only compile application files (dependencies are in ES5 already)
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: [{
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
2018-02-21 12:07:34 -05:00
|
|
|
presets: [
|
|
|
|
['env', { modules: false }]
|
|
|
|
],
|
2018-01-12 06:41:02 -05:00
|
|
|
// Configure babel-loader to cache compiled output so that subsequent
|
|
|
|
// compile runs are much faster
|
|
|
|
cacheDirectory: true
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
// plugins: {}
|
|
|
|
}
|