When I run : webpack-dev-server
, it compiles code and gives the output in browser.
But when I run : webpack - p
it did not generate the files in dist
folder, it did not even create the folder dist
Here are the some of files and the directory structure of my project
webpack.config.babel.js
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin,{extract} from 'extract-text-webpack-plugin';
import path,{resolve} from 'path';
module.exports = {
devtool: 'source-map',
entry: './src/app.js',
output: {
path: resolve(__dirname + 'dist'),
filename : 'app.bundle.js'
},
module: {
rules:[
{
test: /\.scss$/,
exclude: /node_modules/,
use: extract({
fallback: "style-loader",
use: [
"css-loader",
"sass-loader",
],
publicPath: "/dist"
}),
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
},
devServer:{
contentBase: path.join(__dirname, "dist"),
compress: true,
port: 9000,
stats:'errors-only'
},
plugins: [
new HtmlWebpackPlugin({
title: 'Webpack starter project',
template: './src/index.html',
hash:true,
minify:{
collapseWhitespace: true,
minifyCSS: true,
minifyJS:true,
}
}),
new ExtractTextPlugin({
filename: "app.css",
disable: false,
allChunks: true
})
]
}
A normal webpack file wouldn't understand ES6/7 features. So in case if you want to use them inside your webpack configuration, you gotta call the command in the following way as mentioned below.
$ webpack -p --config webpack.config.babel.js
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.