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
|
|
|
|
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',
|
|
|
|
{
|
2020-03-13 22:30:39 +08:00
|
|
|
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 {
|
2020-03-13 22:30:39 +08:00
|
|
|
// 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/boot': path.join(devPathJoin, 'boot.js'),
|
|
|
|
'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
|
|
|
|
},
|
2018-03-30 05:43:46 +08:00
|
|
|
plugins: [
|
2020-03-13 22:30:39 +08:00
|
|
|
// new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
2018-03-30 05:43:46 +08:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'RL_COMMUNITY': !pro,
|
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
|
|
|
'Opentip$': path.join(externalPathJoin, 'Opentip.js'),
|
|
|
|
'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: {
|
|
|
|
'window': 'window',
|
|
|
|
'progressJs': 'window.progressJs',
|
|
|
|
'moment': 'window.moment',
|
|
|
|
'ifvisible': 'window.ifvisible',
|
|
|
|
'crossroads': 'window.crossroads',
|
|
|
|
'hasher': 'window.hasher',
|
|
|
|
'Jua': 'window.Jua',
|
|
|
|
'Autolinker': 'window.Autolinker',
|
|
|
|
'ssm': 'window.ssm',
|
|
|
|
'key': 'window.key',
|
|
|
|
'_': 'window._',
|
|
|
|
'qr': 'window.qr',
|
|
|
|
'$': 'window.jQuery'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|