Commit 9fff44bd authored by Matija Obreza's avatar Matija Obreza
Browse files

Webpack entrypoint

- Don't watch node_modules
parent e43964a7
......@@ -13,127 +13,129 @@ const ReactLoadable = require('react-loadable/webpack');
const fs = require('fs');
const HOST = process.env.HOST || 'localhost';
const HOST = process.env.HOST || '0.0.0.0';
const PORT = process.env.PORT || 3000;
module.exports = {
stats: {
colors: true
},
devServer: {
hot: true,
inline: true,
contentBase: path.join(__dirname, '../'),
compress: true,
port: PORT,
host: HOST,
overlay: {
warnings: true,
errors: true
},
clientLogLevel: 'warning',
historyApiFallback: {
disableDotRule: true
},
},
entry: {
gringlobal: [ 'babel-polyfill', './demo/App.tsx' ],
},
output: {
filename: '[name].[hash].js',
chunkFilename: '[name].[hash].js',
path: path.join(process.cwd(), 'target/app/assets'),
publicPath: ''
stats: {
colors: true
},
devServer: {
hot: true,
inline: true,
// contentBase: path.join(__dirname, '../'),
compress: true,
port: PORT,
host: HOST,
watchOptions: {
ignored: /node_modules/
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
modules: [path.resolve('./src'), path.resolve('./server'), 'node_modules'],
alias: {
'@gringlobal/counter': path.resolve(__dirname, '../src'),
'@gringlobal/i18n': path.resolve(__dirname, '../../i18n/src'),
'server': path.resolve(__dirname, '../server'),
}
overlay: {
warnings: true,
errors: true
},
module: {
rules: [
{
test: /\.tsx?$/,
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/,
},
{
test: /\.tsx?$/,
use: [
{
loader: 'awesome-typescript-loader',
},
],
},
]
clientLogLevel: 'warning',
historyApiFallback: {
disableDotRule: true
},
plugins: [
/* new webpack.optimize.CommonsChunkPlugin({
},
entry: {
gringlobal: ['babel-polyfill', './demo/entrypoint.tsx'],
},
output: {
filename: '[name].[hash].js',
chunkFilename: '[name].[hash].js',
path: path.join(process.cwd(), 'target/app/assets'),
publicPath: ''
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
modules: [path.resolve('./src'), path.resolve('./server'), 'node_modules'],
alias: {
'@gringlobal/counter': path.resolve(__dirname, '../src'),
'@gringlobal/i18n': path.resolve(__dirname, '../../i18n/src'),
'server': path.resolve(__dirname, '../server'),
}
},
module: {
rules: [
{
test: /\.tsx?$/,
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/,
},
{
test: /\.tsx?$/,
use: [
{
loader: 'awesome-typescript-loader',
},
],
},
]
},
plugins: [
/* new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity
}),*/
// MD5 chunkhash
new WebpackChunkHash(),
// We use the generated manifest.js to look for current server.[hash].js and vendor.[chunkhash].js
new ManifestPlugin({
basePath: '/html/'
}),
new HtmlWebpackPlugin({
title: 'Seed counter', // The title to use for the generated HTML document
filename: 'index.html', // The file to write the HTML to
// minify: {...}, // Pass a html-minifier options object to minify the output
xhtml: true,
excludeAssets: [/server(\..+)*\.js/],
template: './assets/html/index.html',
// chunksSortMode: sortedChunks(['vendor', 'common', 'gringlobal']),
// chunks: ['vendor', 'common', 'gringlobal'],
favicon: 'favicon.ico',
}),
// Defer/Async scripts
new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'async',
// async: [ 'gringlobal' ],
}),
// Keep CSS separate
new MiniCssExtractPlugin({
filename: '[name].[hash].css',
chunkFilename: '[name].[hash].css'
}),
new HtmlWebpackExcludeAssetsPlugin(),
new CopyWebpackPlugin([
{ from: 'assets/examples', to: 'examples' },
]),
],
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all'
}
},
},
}
// MD5 chunkhash
new WebpackChunkHash(),
// We use the generated manifest.js to look for current server.[hash].js and vendor.[chunkhash].js
new ManifestPlugin({
basePath: '/html/'
}),
new HtmlWebpackPlugin({
title: 'Seed counter', // The title to use for the generated HTML document
filename: 'index.html', // The file to write the HTML to
// minify: {...}, // Pass a html-minifier options object to minify the output
xhtml: true,
excludeAssets: [/server(\..+)*\.js/],
template: './assets/html/index.html',
// chunksSortMode: sortedChunks(['vendor', 'common', 'gringlobal']),
// chunks: ['vendor', 'common', 'gringlobal'],
favicon: 'favicon.ico',
}),
// Defer/Async scripts
new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'async',
// async: [ 'gringlobal' ],
}),
// Keep CSS separate
new MiniCssExtractPlugin({
filename: '[name].[hash].css',
chunkFilename: '[name].[hash].css'
}),
new HtmlWebpackExcludeAssetsPlugin(),
new CopyWebpackPlugin([
{ from: 'assets/examples', to: 'examples' },
]),
],
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all'
}
},
},
}
};
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App />,
document.getElementById('the-app'),
);
......@@ -50,6 +50,9 @@ module.exports = {
compress: true,
port: PORT,
host: HOST,
watchOptions: {
ignored: /node_modules/
},
overlay: {
warnings: true,
errors: true
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment