snappymail/webpack.config.builder.js

136 lines
3 KiB
JavaScript
Raw Normal View History

2019-07-05 03:09:27 +08:00
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
2018-03-30 05:43:46 +08:00
2019-07-05 03:09:27 +08:00
const devPath = path.resolve(__dirname, 'dev');
const devPathJoin = path.join(__dirname, 'dev');
const externalPathJoin = path.join(__dirname, 'dev', 'External');
const loose = true;
2018-03-30 05:43:46 +08:00
//npm install closure-webpack-plugin google-closure-compiler
//const ClosurePlugin = require('closure-webpack-plugin');
2018-10-06 07:13:58 +08:00
const babelLoaderOptions = function() {
return {
2019-07-05 03:09:27 +08:00
ignore: [/\/core-js/],
2018-10-06 07:13:58 +08:00
cacheDirectory: true,
2019-07-05 03:09:27 +08:00
overrides: [
{
test: './node_modules/',
sourceType: 'unambiguous'
}
],
2018-10-06 07:13:58 +08:00
presets: [
2019-07-05 03:09:27 +08:00
[
'@babel/preset-env',
{
targets: {"chrome": "60"},
// useBuiltIns: 'usage',
// corejs: { version: 3, proposals: true },
2019-07-05 03:09:27 +08:00
loose: loose,
modules: false
}
]
2018-10-06 07:13:58 +08:00
],
plugins: [
2019-07-05 03:09:27 +08:00
[
'@babel/plugin-proposal-decorators',
{
legacy: true
}
],
2018-10-06 07:13:58 +08:00
'@babel/plugin-proposal-class-properties'
]
};
};
2018-03-30 05:43:46 +08:00
process.noDeprecation = true;
2019-03-30 06:45:12 +08:00
module.exports = function(publicPath, pro, mode) {
2018-03-30 05:43:46 +08:00
return {
// mode: 'production',
2019-03-30 06:45:12 +08:00
mode: mode || 'development',
2019-07-05 03:09:27 +08:00
devtool: 'inline-source-map',
2018-03-30 05:43:46 +08:00
entry: {
2019-03-30 06:45:12 +08:00
'js/app': path.join(devPathJoin, 'app.js'),
'js/admin': path.join(devPathJoin, 'admin.js')
2018-03-30 05:43:46 +08:00
},
output: {
pathinfo: true,
path: path.join(__dirname, 'rainloop', 'v', '0.0.0', 'static'),
filename: '[name].js',
publicPath: publicPath || 'rainloop/v/0.0.0/static/'
},
2018-10-06 07:13:58 +08:00
performance: {
hints: false
},
2018-09-19 04:35:41 +08:00
optimization: {
concatenateModules: false,
minimize: false
/*
,minimizer: [
new ClosurePlugin({mode: 'STANDARD'}, {
language_in:'ECMASCRIPT6',
language_out:'ECMASCRIPT6',
compilation_level: 'ADVANCED_OPTIMIZATIONS'
// compiler flags here
//
// for debugging help, try these:
//
// formatting: 'PRETTY_PRINT'
// debug: true,
// renaming: false
})
]
*/
2018-09-19 04:35:41 +08:00
},
2018-03-30 05:43:46 +08:00
plugins: [
// new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
2018-03-30 05:43:46 +08:00
new webpack.DefinePlugin({
2019-06-29 08:17:29 +08:00
'process.env.NODE_ENV': JSON.stringify('production'),
2018-03-30 05:43:46 +08:00
'process.env': {
2019-06-29 08:17:29 +08:00
NODE_ENV: JSON.stringify('production')
2018-03-30 05:43:46 +08:00
}
}),
2019-07-05 03:09:27 +08:00
new webpack.DefinePlugin({}),
2018-03-30 05:43:46 +08:00
new CopyWebpackPlugin([
2019-07-05 03:09:27 +08:00
{ from: 'node_modules/openpgp/dist/openpgp.min.js', to: 'js/min/openpgp.min.js' },
{ from: 'node_modules/openpgp/dist/openpgp.worker.min.js', to: 'js/min/openpgp.worker.min.js' }
2018-03-30 05:43:46 +08:00
])
],
resolve: {
modules: [devPath, 'node_modules'],
extensions: ['.js'],
alias: {
2019-03-30 06:45:12 +08:00
'ko$': path.join(externalPathJoin, 'ko.js')
2018-03-30 05:43:46 +08:00
}
},
module: {
rules: [
{
2018-10-06 07:13:58 +08:00
test: /\.js$/,
2018-03-30 05:43:46 +08:00
loader: 'babel-loader',
include: [devPath],
2018-10-06 07:13:58 +08:00
options: babelLoaderOptions()
2018-03-30 05:43:46 +08:00
},
{
2019-03-28 06:01:26 +08:00
test: /\.html$/,
2018-03-30 05:43:46 +08:00
loader: 'raw-loader',
include: [devPath]
},
2019-03-28 06:01:26 +08:00
{
test: /\.css/,
loaders: ['style-loader', 'css-loader'],
include: [devPath]
},
2018-03-30 05:43:46 +08:00
{
test: /\.json$/,
loader: 'json-loader',
include: [devPath]
}
]
},
externals: {
}
};
};