Doodle3D-Slicer/webpack.config.js

79 lines
2.0 KiB
JavaScript
Raw Normal View History

2017-07-20 12:12:25 +02:00
const path = require('path');
2018-01-18 11:40:57 +01:00
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
2017-07-20 12:12:25 +02:00
const HTMLWebpackPlugin = require('html-webpack-plugin');
2018-01-18 11:40:57 +01:00
const devMode = process.env.NODE_ENV !== 'production';
const analyzeBundle = process.env.ANALYZE_BUNDLE;
2017-07-20 12:12:25 +02:00
const babelLoader = {
loader: 'babel-loader',
options: {
presets: [
2017-11-11 20:23:45 +01:00
require('babel-preset-env'),
2017-12-19 16:23:45 +01:00
require('babel-preset-stage-0'),
2017-11-11 20:23:45 +01:00
require('babel-preset-react')
],
plugins: [
2017-12-21 12:49:44 +01:00
require('babel-plugin-transform-class-properties'),
2017-11-11 20:23:45 +01:00
require('babel-plugin-transform-object-rest-spread'),
2017-12-19 16:00:27 +01:00
require('babel-plugin-transform-runtime'),
2017-12-19 16:23:45 +01:00
require('babel-plugin-transform-es2015-classes')
2017-07-20 12:12:25 +02:00
],
2017-07-20 16:14:01 +02:00
babelrc: false
2017-07-20 12:12:25 +02:00
}
2017-11-11 20:23:45 +01:00
};
2017-07-20 12:12:25 +02:00
module.exports = {
entry: './index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
resolve: {
alias: {
2017-11-16 22:40:39 +01:00
'doodle3d-slicer': path.resolve(__dirname, 'src/'),
2017-07-24 17:47:03 +02:00
'clipper-lib': '@doodle3d/clipper-lib',
'clipper-js': '@doodle3d/clipper-js',
'doodle3d-core': `@doodle3d/doodle3d-core/${devMode ? 'module' : 'lib'}`,
'cal': '@doodle3d/cal'
2017-07-20 12:12:25 +02:00
}
},
module: {
2017-12-21 12:49:44 +01:00
rules: [
2017-07-20 12:12:25 +02:00
{
test: /\.js$/,
exclude: /node_modules/,
use: babelLoader
2017-11-11 20:23:45 +01:00
}, { // make THREE global available to three.js examples
test: /three\/examples\/.+\.js/,
use: 'imports-loader?THREE=three'
}, {
2017-07-20 12:12:25 +02:00
test: /\.yml$/,
2017-07-20 16:58:42 +02:00
use: 'yml-loader'
2017-11-11 20:23:45 +01:00
}, {
2017-07-20 12:12:25 +02:00
test: /\.worker\.js$/,
use: ['worker-loader', babelLoader]
}, {
test: /\.(png|jpg|gif)$/,
use: ['url-loader?name=images/[name].[ext]']
2017-12-06 11:54:09 +01:00
}, {
test: /\.glsl$/,
use: ['raw-loader']
2017-07-20 12:12:25 +02:00
}
]
},
2018-01-18 11:40:57 +01:00
plugins: analyzeBundle ? [new BundleAnalyzerPlugin()] : [
2017-07-20 12:12:25 +02:00
new HTMLWebpackPlugin({
2018-01-17 09:02:50 +01:00
title: 'Doodle3D Slicer',
2017-11-11 20:23:45 +01:00
template: require('html-webpack-template'),
inject: false,
appMountId: 'app'
2018-01-18 11:40:57 +01:00
})
2017-07-20 12:12:25 +02:00
],
2018-01-18 12:06:14 +01:00
devtool: false,
devtool: devMode ? 'source-map' : false,
2017-07-20 12:12:25 +02:00
devServer: {
contentBase: 'dist'
}
};