2018-02-13 22:01:28 +00:00
|
|
|
require('require-yaml');
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const path = require('path');
|
|
|
|
const merge = require('webpack-merge');
|
2018-12-27 11:54:16 +00:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2018-12-21 10:36:44 +00:00
|
|
|
let env = process.env.NODE_ENV || 'development';
|
|
|
|
let mode = env == 'development' ? env : 'production';
|
2018-12-20 13:37:29 +00:00
|
|
|
|
2018-02-13 22:01:28 +00:00
|
|
|
let baseConfig = {
|
2019-01-25 22:02:29 +00:00
|
|
|
entry: {salix: 'salix'},
|
2018-12-20 13:37:29 +00:00
|
|
|
mode: mode,
|
2017-01-31 13:13:06 +00:00
|
|
|
output: {
|
2019-01-25 22:02:29 +00:00
|
|
|
path: path.join(__dirname, 'dist'),
|
|
|
|
publicPath: '/'
|
2017-01-31 13:13:06 +00:00
|
|
|
},
|
|
|
|
module: {
|
2018-02-08 12:47:54 +00:00
|
|
|
rules: [
|
2017-01-31 13:13:06 +00:00
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
loader: 'babel-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
query: {
|
2019-01-26 01:30:46 +00:00
|
|
|
presets: ['@babel/preset-env'],
|
|
|
|
plugins: ['@babel/plugin-syntax-dynamic-import']
|
2017-01-31 13:13:06 +00:00
|
|
|
}
|
2018-02-04 18:39:56 +00:00
|
|
|
}, {
|
|
|
|
test: /\.yml$/,
|
|
|
|
loader: 'json-loader!yaml-loader'
|
|
|
|
}, {
|
2017-01-31 13:13:06 +00:00
|
|
|
test: /\.html$/,
|
2019-02-05 08:13:15 +00:00
|
|
|
loader: 'html-loader',
|
|
|
|
options: {
|
|
|
|
attrs: [
|
|
|
|
'img:src',
|
|
|
|
'link:href'
|
|
|
|
]
|
|
|
|
}
|
2018-02-04 18:39:56 +00:00
|
|
|
}, {
|
2017-01-31 13:13:06 +00:00
|
|
|
test: /\.css$/,
|
2019-02-06 10:24:29 +00:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'style-loader'
|
|
|
|
}, {
|
|
|
|
loader: 'css-loader'
|
|
|
|
}
|
|
|
|
]
|
2018-02-04 18:39:56 +00:00
|
|
|
}, {
|
2017-01-31 13:13:06 +00:00
|
|
|
test: /\.scss$/,
|
2018-05-14 10:54:17 +00:00
|
|
|
use: [
|
|
|
|
{
|
2019-02-06 10:24:29 +00:00
|
|
|
loader: 'style-loader'
|
|
|
|
}, {
|
|
|
|
loader: 'css-loader'
|
|
|
|
}, {
|
2018-05-14 10:54:17 +00:00
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
2019-10-14 10:01:19 +00:00
|
|
|
// XXX: Don't work in Firefox
|
2019-02-06 10:24:29 +00:00
|
|
|
// https://github.com/webpack-contrib/style-loader/issues/303
|
|
|
|
// sourceMap: true,
|
2018-05-14 10:54:17 +00:00
|
|
|
includePaths: [
|
2019-10-04 22:16:57 +00:00
|
|
|
path.resolve(__dirname, 'front/core/styles')
|
2018-05-14 10:54:17 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2018-02-04 18:39:56 +00:00
|
|
|
}, {
|
2017-02-21 11:49:41 +00:00
|
|
|
test: /\.(svg|png|ttf|woff|woff2)$/,
|
2017-01-31 13:13:06 +00:00
|
|
|
loader: 'file-loader'
|
2019-02-05 08:13:15 +00:00
|
|
|
}, {
|
|
|
|
test: /manifest\.json$/,
|
|
|
|
type: 'javascript/auto',
|
|
|
|
loader: 'file-loader'
|
2017-01-31 13:13:06 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2018-12-20 13:37:29 +00:00
|
|
|
optimization: {
|
2018-12-21 10:36:44 +00:00
|
|
|
runtimeChunk: true,
|
2018-12-20 13:37:29 +00:00
|
|
|
splitChunks: {
|
|
|
|
chunks: 'all',
|
2018-12-21 10:36:44 +00:00
|
|
|
}
|
2018-12-20 13:37:29 +00:00
|
|
|
},
|
2017-01-31 13:13:06 +00:00
|
|
|
resolve: {
|
|
|
|
modules: [
|
2018-12-27 11:54:16 +00:00
|
|
|
`front`,
|
|
|
|
`modules`,
|
|
|
|
`front/node_modules`,
|
|
|
|
`node_modules`
|
2018-09-13 13:19:50 +00:00
|
|
|
],
|
|
|
|
alias: {
|
2018-12-27 11:54:16 +00:00
|
|
|
'vn-loopback': `${__dirname}/loopback`
|
2018-09-13 13:19:50 +00:00
|
|
|
}
|
2017-01-31 13:13:06 +00:00
|
|
|
},
|
2019-01-28 11:14:22 +00:00
|
|
|
watchOptions: {
|
|
|
|
ignored: [
|
|
|
|
'node_modules',
|
|
|
|
'./modules/*/back/**'
|
|
|
|
]
|
|
|
|
},
|
2017-01-31 13:13:06 +00:00
|
|
|
plugins: [
|
2018-12-27 11:54:16 +00:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: 'front/salix/index.ejs',
|
2019-01-25 22:02:29 +00:00
|
|
|
favicon: 'front/salix/favicon.ico',
|
2018-12-27 11:54:16 +00:00
|
|
|
filename: 'index.html',
|
|
|
|
chunks: ['salix']
|
2017-05-16 10:37:48 +00:00
|
|
|
})
|
2017-01-31 13:13:06 +00:00
|
|
|
],
|
2018-12-20 13:37:29 +00:00
|
|
|
devtool: 'source-map',
|
2019-01-28 11:16:22 +00:00
|
|
|
stats: {
|
2018-12-21 10:36:44 +00:00
|
|
|
assets: false,
|
2019-10-15 14:19:35 +00:00
|
|
|
modules: false,
|
2018-12-27 11:54:16 +00:00
|
|
|
children: false,
|
2019-01-28 11:16:22 +00:00
|
|
|
entrypoints: false,
|
2018-12-20 13:37:29 +00:00
|
|
|
colors: true
|
|
|
|
}
|
2017-01-31 13:13:06 +00:00
|
|
|
};
|
2018-01-29 11:37:54 +00:00
|
|
|
|
2018-02-13 22:01:28 +00:00
|
|
|
let prodConfig = {
|
|
|
|
output: {
|
|
|
|
filename: '[name].[chunkhash].js',
|
2018-12-20 13:37:29 +00:00
|
|
|
chunkFilename: '[id].[chunkhash].js'
|
2018-02-13 22:01:28 +00:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.HashedModuleIdsPlugin()
|
2018-12-20 13:37:29 +00:00
|
|
|
],
|
|
|
|
performance: {
|
|
|
|
maxEntrypointSize: 2000000,
|
|
|
|
maxAssetSize: 2000000
|
|
|
|
}
|
2018-02-13 22:01:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
let devConfig = {
|
|
|
|
output: {
|
|
|
|
filename: '[name].js',
|
2018-12-20 13:37:29 +00:00
|
|
|
chunkFilename: '[id].js'
|
2018-02-13 22:01:28 +00:00
|
|
|
},
|
2019-01-26 12:12:18 +00:00
|
|
|
plugins: [
|
|
|
|
new webpack.HotModuleReplacementPlugin()
|
|
|
|
],
|
2018-12-20 13:37:29 +00:00
|
|
|
devServer: {
|
2019-02-01 08:31:01 +00:00
|
|
|
host: '0.0.0.0',
|
2019-01-25 22:02:29 +00:00
|
|
|
port: 5000,
|
2018-12-20 13:37:29 +00:00
|
|
|
publicPath: '/',
|
2019-01-25 22:02:29 +00:00
|
|
|
contentBase: 'dist',
|
2018-12-20 13:37:29 +00:00
|
|
|
quiet: false,
|
|
|
|
noInfo: false,
|
2019-01-26 12:12:18 +00:00
|
|
|
hot: true,
|
|
|
|
inline: true,
|
2019-01-25 22:02:29 +00:00
|
|
|
stats: baseConfig.stats,
|
|
|
|
proxy: {
|
|
|
|
'/api': 'http://localhost:3000',
|
|
|
|
'/*/api/**': {
|
|
|
|
target: 'http://localhost:3000',
|
|
|
|
pathRewrite: {'^/[\\w-]+': ''}
|
|
|
|
}
|
|
|
|
}
|
2018-12-20 13:37:29 +00:00
|
|
|
}
|
2018-02-13 22:01:28 +00:00
|
|
|
};
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2018-12-21 10:36:44 +00:00
|
|
|
let mrgConfig = mode === 'development' ? devConfig : prodConfig;
|
2018-02-13 22:01:28 +00:00
|
|
|
module.exports = merge(baseConfig, mrgConfig);
|