mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-03-27 22:55:56 +08:00
ES modules are the default package export. Commonjs modules are exported from 'dist/cjs'. Modern bundlers like webpack can consume ES modules. The addition of the `sideEffects:false` to the `package.json` helps webpack tree-shaking modules.
53 lines
1.1 KiB
JavaScript
53 lines
1.1 KiB
JavaScript
const babelPreset = require('../../scripts/babel/preset');
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
const path = require('path');
|
|
|
|
const appDirectory = path.resolve(__dirname);
|
|
|
|
module.exports = {
|
|
mode: 'production',
|
|
context: __dirname,
|
|
entry: './src/index',
|
|
output: {
|
|
path: path.resolve(appDirectory, 'dist'),
|
|
filename: 'bundle.js'
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.css$/,
|
|
use: [
|
|
'style-loader',
|
|
{
|
|
loader: 'css-loader',
|
|
options: { module: true, localIdentName: '[hash:base64:8]' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /\.js$/,
|
|
include: [path.resolve(appDirectory, 'src')],
|
|
use: {
|
|
loader: 'babel-loader',
|
|
options: {
|
|
cacheDirectory: false,
|
|
presets: babelPreset,
|
|
plugins: ['styled-jsx/babel']
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new BundleAnalyzerPlugin({
|
|
analyzerMode: 'static',
|
|
openAnalyzer: false
|
|
})
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'react-native': 'react-native-web'
|
|
}
|
|
}
|
|
};
|