Doodle3D-Core/webpack.config.js

98 lines
2.5 KiB
JavaScript
Raw Permalink Normal View History

2017-12-07 16:21:10 +01:00
const webpack = require('webpack');
2017-11-15 15:13:49 +01:00
const path = require('path');
2017-12-05 16:28:19 +01:00
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
2017-11-15 15:13:49 +01:00
const HTMLWebpackPlugin = require('html-webpack-plugin');
2017-12-07 16:21:10 +01:00
const CordovaPlugin = require('webpack-cordova-plugin');
2017-11-15 15:13:49 +01:00
2017-11-15 17:00:30 +01:00
const devMode = process.env.NODE_ENV !== 'production';
2017-12-07 16:21:10 +01:00
const appMode = process.env.TARGET === 'app';
2017-11-15 17:00:30 +01:00
2017-11-15 15:13:49 +01:00
const babelLoader = {
loader: 'babel-loader',
options: {
presets: [
require('babel-preset-env'),
require('babel-preset-react')
],
plugins: [
require('babel-plugin-transform-object-rest-spread'),
require('babel-plugin-transform-class-properties'),
require('babel-plugin-transform-runtime')
],
babelrc: false
}
};
module.exports = {
entry: './index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: babelLoader
}, { // make THREE global available to three.js examples
test: /three\/examples\/.+\.js/,
use: 'imports-loader?THREE=three'
}, {
test: /\.yml$/,
use: 'yml-loader'
}, {
test: /\.worker.js$/,
use: ['worker-loader', babelLoader]
}, {
test: /\.(png|jpg|gif)$/,
use: {
2017-12-11 11:45:57 +01:00
loader: 'url-loader?name=images/[name].[ext]'
2017-11-15 15:13:49 +01:00
}
}, {
2018-06-21 16:10:13 +02:00
test: /\.(svg|glsl|d3sketch|doodle3d)$/,
2017-11-15 15:13:49 +01:00
use: {
loader: 'raw-loader'
}
2021-05-05 19:44:31 +02:00
}, {
test: /\.(woff)$/,
2021-05-20 04:16:53 +02:00
use: {
2021-05-05 19:44:31 +02:00
loader: 'file-loader'
}
2017-11-23 10:51:52 +01:00
}, {
test: /\.css$/,
2018-01-06 20:27:14 +01:00
use: ['style-loader', 'css-loader']
2017-11-15 15:13:49 +01:00
}
]
},
plugins: [
2017-12-07 16:21:10 +01:00
new webpack.DefinePlugin({
'process.env.TARGET': JSON.stringify(process.env.TARGET)
2017-12-07 16:21:10 +01:00
}),
2017-11-15 15:13:49 +01:00
new HTMLWebpackPlugin({
2017-11-15 16:12:33 +01:00
title: 'Doodle3D Core - Simple example',
2018-01-31 14:27:05 +01:00
favicon: './favicon.ico',
template: require('html-webpack-template'),
inject: false,
2018-02-14 14:53:07 +01:00
mobile: false,
2018-01-31 14:27:05 +01:00
scripts: appMode ? ['cordova.js'] : null,
2018-01-31 14:31:56 +01:00
appMountId: 'app',
meta: [
{ name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, minimal-ui, user-scalable=no' }
]
2017-11-15 15:13:49 +01:00
}),
2017-12-07 16:21:10 +01:00
...(appMode ? [
new CordovaPlugin({
config: 'config.xml',
src: 'index.html',
platform: 'ios',
version: true
})
] : [])
2017-11-15 15:13:49 +01:00
],
devtool: 'source-map',
2017-11-15 15:13:49 +01:00
devServer: {
contentBase: 'dist'
}
};