2018-02-13 22:01:28 +00:00
|
|
|
require('require-yaml');
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const path = require('path');
|
|
|
|
const merge = require('webpack-merge');
|
|
|
|
const AssetsWebpackPlugin = require('assets-webpack-plugin');
|
|
|
|
const wpConfig = require('./webpack.config.yml');
|
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 outputPath = path.join(__dirname, wpConfig.buildDir);
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2018-02-13 22:01:28 +00:00
|
|
|
let baseConfig = {
|
|
|
|
entry: wpConfig.entry,
|
2018-12-20 13:37:29 +00:00
|
|
|
mode: mode,
|
2017-01-31 13:13:06 +00:00
|
|
|
output: {
|
2018-02-13 22:01:28 +00:00
|
|
|
path: outputPath,
|
|
|
|
publicPath: `${wpConfig.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: {
|
2018-12-20 13:37:29 +00:00
|
|
|
presets: ['@babel/preset-env']
|
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$/,
|
|
|
|
loader: 'html-loader'
|
2018-02-04 18:39:56 +00:00
|
|
|
}, {
|
2017-01-31 13:13:06 +00:00
|
|
|
test: /\.css$/,
|
|
|
|
loader: 'style-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: [
|
|
|
|
{loader: 'style-loader'},
|
|
|
|
{loader: 'css-loader'},
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
includePaths: [
|
2018-12-22 10:59:26 +00:00
|
|
|
path.resolve(__dirname, 'front/salix/src/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'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
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-22 10:59:26 +00:00
|
|
|
`${__dirname}/front`,
|
|
|
|
`${__dirname}/modules`,
|
|
|
|
'front/node_modules',
|
2018-02-08 12:47:54 +00:00
|
|
|
'node_modules'
|
2018-09-13 13:19:50 +00:00
|
|
|
],
|
|
|
|
alias: {
|
|
|
|
'vn-loopback': `${__dirname}/services/loopback`
|
|
|
|
}
|
2017-01-31 13:13:06 +00:00
|
|
|
},
|
|
|
|
plugins: [
|
2018-12-20 13:37:29 +00:00
|
|
|
new AssetsWebpackPlugin({
|
|
|
|
path: outputPath
|
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',
|
|
|
|
stats: {
|
|
|
|
modules: false,
|
2018-12-21 10:36:44 +00:00
|
|
|
assets: 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
|
|
|
},
|
2018-12-20 13:37:29 +00:00
|
|
|
devServer: {
|
2018-12-21 10:36:44 +00:00
|
|
|
host: 'localhost',
|
2018-12-20 13:37:29 +00:00
|
|
|
port: wpConfig.devServerPort,
|
|
|
|
publicPath: '/',
|
|
|
|
contentBase: wpConfig.buildDir,
|
|
|
|
quiet: false,
|
|
|
|
noInfo: false,
|
|
|
|
// hot: true,
|
|
|
|
stats: baseConfig.stats
|
|
|
|
}
|
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);
|