2019-06-20 19:37:28 +07:00
|
|
|
const env = require('../config/env');
|
2019-04-05 02:23:40 +07:00
|
|
|
const StyleLintPlugin = require('stylelint-webpack-plugin');
|
2019-02-03 17:23:33 +07:00
|
|
|
|
|
|
|
module.exports = {
|
2019-06-20 19:37:28 +07:00
|
|
|
entry: `${env.SRC_ROOT}/index.tsx`,
|
2019-02-03 17:23:33 +07:00
|
|
|
|
|
|
|
output: {
|
2019-04-05 02:23:40 +07:00
|
|
|
path: `${env.APP_ROOT}/static/`,
|
|
|
|
filename: '[name].[hash].js',
|
2019-08-25 22:53:30 +07:00
|
|
|
publicPath: '/-/static',
|
2019-02-03 17:23:33 +07:00
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
2019-06-20 19:37:28 +07:00
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
2019-02-03 17:23:33 +07:00
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
new StyleLintPlugin({
|
2019-06-20 19:37:28 +07:00
|
|
|
files: ['src/**/styles.ts'],
|
2019-02-03 17:23:33 +07:00
|
|
|
failOnError: false,
|
2019-06-20 19:37:28 +07:00
|
|
|
emitErrors: true,
|
2019-04-05 02:23:40 +07:00
|
|
|
}),
|
2019-02-03 17:23:33 +07:00
|
|
|
],
|
|
|
|
|
|
|
|
optimization: {
|
|
|
|
runtimeChunk: {
|
2019-04-05 02:23:40 +07:00
|
|
|
name: 'manifest',
|
2019-02-03 17:23:33 +07:00
|
|
|
},
|
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
vendor: {
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
2019-04-05 02:23:40 +07:00
|
|
|
name: 'vendors',
|
2019-02-03 17:23:33 +07:00
|
|
|
priority: -20,
|
2019-04-05 02:23:40 +07:00
|
|
|
chunks: 'all',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-02-03 17:23:33 +07:00
|
|
|
},
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [
|
2019-04-05 02:23:40 +07:00
|
|
|
/* Pre loader */
|
|
|
|
{
|
|
|
|
enforce: 'pre',
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: 'eslint-loader',
|
|
|
|
},
|
2019-02-03 17:23:33 +07:00
|
|
|
|
|
|
|
/* Normal loader */
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2019-04-05 02:23:40 +07:00
|
|
|
use: 'babel-loader',
|
2019-02-03 17:23:33 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(jpe?g|png|gif|svg)$/,
|
|
|
|
use: [
|
|
|
|
{
|
2019-06-20 19:37:28 +07:00
|
|
|
loader: 'file-loader',
|
2019-04-05 02:23:40 +07:00
|
|
|
},
|
2019-06-20 19:37:28 +07:00
|
|
|
],
|
2019-02-03 17:23:33 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
2019-04-05 02:23:40 +07:00
|
|
|
loader: 'url-loader',
|
2019-02-03 17:23:33 +07:00
|
|
|
options: {
|
2019-09-29 21:36:38 +07:00
|
|
|
name: '/fonts/[name].[ext]',
|
2019-04-05 02:23:40 +07:00
|
|
|
limit: 50,
|
|
|
|
},
|
2019-02-03 17:23:33 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [
|
|
|
|
{
|
2019-04-05 02:23:40 +07:00
|
|
|
loader: 'style-loader',
|
2019-02-03 17:23:33 +07:00
|
|
|
},
|
|
|
|
{
|
2019-04-05 02:23:40 +07:00
|
|
|
loader: 'css-loader',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2019-06-20 19:37:28 +07:00
|
|
|
|
|
|
|
/* Typescript loader */
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
use: 'babel-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
},
|
2019-04-05 02:23:40 +07:00
|
|
|
],
|
2019-02-03 17:23:33 +07:00
|
|
|
},
|
|
|
|
|
|
|
|
stats: {
|
2019-04-05 02:23:40 +07:00
|
|
|
children: false,
|
|
|
|
},
|
2019-02-03 17:23:33 +07:00
|
|
|
};
|