markdown 的WebPack
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 的WebPack相关的知识,希望对你有一定的参考价值。
#### Instalación
```bash
npm install webpack webpack-cli webpack-dev-server style-loader css-loader file-loader babel-loader babel-core babel-preset-env --save-dev
```
#### webpack.config.js
```js
const path = require('path');
module.exports = {
entry: './src/main.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
devtool: 'source-map',
devServer: {
contentBase: './dist'
},
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader'
]
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
},
optimization: {
minimize: true
}
};
```
#### package.json
```json
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --watch",
"start": "webpack-dev-server"
},
```
- Poner a correr webpack watch en una consola y webpack server en otra
以上是关于markdown 的WebPack的主要内容,如果未能解决你的问题,请参考以下文章
markdown 的WebPack
markdown 的WebPack
markdown 的WebPack-HMR
markdown 的WebPack
markdown 的WebPack&汇总与包裹对比
markdown Webpack,es6,postcss