Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yuanyu90221/webpack-demo-dir
https://github.com/yuanyu90221/webpack-demo-dir
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/yuanyu90221/webpack-demo-dir
- Owner: yuanyu90221
- Created: 2019-03-19T03:02:10.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-17T10:34:52.000Z (4 months ago)
- Last Synced: 2024-09-17T13:16:19.849Z (4 months ago)
- Language: JavaScript
- Size: 7.04 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# webpack 4.0.X setup
# how to run
## specify with specific mode```
npm run webpack --mode=production
```## set different by mode package rule for webpack.config.js
```
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
let config = {
// package entry point
entry: {
index: './src/index.js'
},
output: {
// final packaged name
filename: 'bundle.js',
// final package path
path: path.resolve('./dist/')
},
plugins: [
new HtmlWebpackPlugin({
filename: `${path.join(__dirname,'dist','index.html')}`,
template: './src/index.html',
title: 'My App'
})
]
}
module.exports = (env, argv ) =>{
if (argv.mode && (argv.mode === 'production' || argv.mode === 'development' )) {
config.mode = argv.mode;
} else {
config.mode = 'development';
}
if (config.mode==='development') {
config.devtool = 'source-map';
} else {
config.devtool = null;
}
return config;
};
```