Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
72 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/env", | ||
{ | ||
"modules": false | ||
} | ||
], | ||
"@babel/react" | ||
["@babel/preset-env", { | ||
"modules": false | ||
}], | ||
"@babel/preset-react" | ||
], | ||
"plugins": [ | ||
"@babel/transform-runtime", | ||
"@babel/proposal-class-properties", | ||
"react-hot-loader/babel" | ||
"@babel/plugin-transform-runtime", | ||
"@babel/plugin-proposal-class-properties" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,5 @@ | |
</head> | ||
<body> | ||
<div id="react-container"></div> | ||
<script src="main.bundle.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,95 @@ | ||
const path = require('path'); | ||
// eslint-disable-next-line import/no-unresolved | ||
|
||
const CopyWebpackPlugin = require('copy-webpack-plugin'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
|
||
const isProduction = process.env.NODE_ENV === 'production'; | ||
const isDevelopment = !isProduction; | ||
|
||
module.exports = { | ||
mode: 'production', | ||
context: __dirname, | ||
devtool: 'source-map', | ||
entry: [ | ||
'./index', | ||
], | ||
mode: isProduction ? 'production' : 'development', | ||
bail: isProduction, | ||
context: path.join(__dirname), | ||
entry: { | ||
src: [ | ||
isDevelopment && 'react-hot-loader/patch', | ||
'./index.jsx', | ||
].filter(Boolean), | ||
}, | ||
output: { | ||
path: path.join(__dirname, 'dist'), | ||
filename: '[name].bundle.js', | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: '[name].[chunkhash:8].js', | ||
}, | ||
resolve: { | ||
extensions: ['.js', '.jsx'], | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.pdf$/, | ||
use: 'url-loader', | ||
test: /\.jsx?$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: { | ||
babelrcRoots: ['.', '../'], | ||
plugins: [isDevelopment && 'react-hot-loader/babel'].filter(Boolean), | ||
}, | ||
}, | ||
], | ||
}, | ||
isDevelopment && { | ||
test: /\.jsx?$/, | ||
include: /node_modules\/react-dom/, | ||
use: 'react-hot-loader/webpack', | ||
}, | ||
{ | ||
test: /\.less$/, | ||
use: [ | ||
'style-loader', | ||
isProduction ? MiniCssExtractPlugin.loader : 'style-loader', | ||
'css-loader', | ||
'less-loader', | ||
], | ||
}, | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
'style-loader', | ||
isProduction ? MiniCssExtractPlugin.loader : 'style-loader', | ||
'css-loader', | ||
], | ||
}, | ||
{ | ||
test: /\.jsx?$/, | ||
exclude: /node_modules/, | ||
loader: 'babel-loader', | ||
options: { babelrcRoots: ['.', '../'] }, | ||
test: /\.pdf$/, | ||
use: 'url-loader', | ||
}, | ||
], | ||
].filter(Boolean), | ||
}, | ||
plugins: [ | ||
new CopyWebpackPlugin([ | ||
{ from: './index.html' }, | ||
{ from: './test.pdf' }, | ||
'test.pdf', | ||
{ from: 'node_modules/pdfjs-dist/cmaps/', to: 'cmaps/' }, | ||
]), | ||
], | ||
new HtmlWebpackPlugin({ | ||
template: 'index.html', | ||
}), | ||
isProduction && new MiniCssExtractPlugin({ | ||
filename: '[name].[chunkhash:8].css', | ||
chunkFilename: '[name].[chunkhash:8].css', | ||
}), | ||
].filter(Boolean), | ||
optimization: { | ||
moduleIds: 'named', | ||
}, | ||
stats: { | ||
assetsSort: '!size', | ||
entrypoints: false, | ||
}, | ||
devServer: { | ||
compress: true, | ||
historyApiFallback: true, // respond to 404s with index.html | ||
host: 'localhost', | ||
hot: true, // enable HMR on the server | ||
port: 3000, | ||
}, | ||
}; |