Doodle3D-Slicer/webpack.config.js

110 lines
2.9 KiB
JavaScript
Raw Normal View History

2017-07-20 12:12:25 +02:00
const path = require('path');
2018-04-17 11:44:51 +02:00
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
2017-07-20 12:12:25 +02:00
const HTMLWebpackPlugin = require('html-webpack-plugin');
2018-04-23 10:55:11 +02:00
const GoogleFontsPlugin = require('google-fonts-webpack-plugin');
2017-07-20 12:12:25 +02:00
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'}`,
2018-01-25 18:03:31 +01:00
'doodle3d-api': `@doodle3d/doodle3d-api/${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$/,
2018-03-06 17:17:05 +01:00
use: [{
loader: 'worker-loader',
options: {
inline: false,
name: '[name].js'
}
2018-04-17 11:44:51 +02:00
}, babelLoader]
}, {
test: /\.(png|jpg|gif)$/,
2018-04-17 11:44:51 +02:00
use: [{
loader: 'file-loader',
options: { name: '[path][name].[ext]' }
},
...(!devMode ? [{
loader: 'image-webpack-loader',
options: {
mozjpeg: { progressive: true, quality: 65 },
optipng: { enabled: false },
pngquant: { quality: '65-90', speed: 4 }
}
}] : [])]
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-30 19:41:30 +01:00
favicon: 'favicon.ico',
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-04-23 10:55:11 +02:00
}),
new GoogleFontsPlugin({
fonts: [
{ family: 'Oswald' },
{ family: 'Ranga' },
{ family: 'Joti One' },
{ family: 'Bellefair' },
{ family: 'Lobster' },
{ family: 'Abril Fatface' },
{ family: 'Play' },
{ family: 'Fascinate' }
]
2018-01-18 11:40:57 +01:00
})
2017-07-20 12:12:25 +02:00
],
2018-01-29 17:13:09 +01:00
devtool: devMode ? 'source-map' : false,
2017-07-20 12:12:25 +02:00
devServer: {
contentBase: 'dist'
}
};