npm install webpack babel-loader babel-core --save-dev
webpack.config.js
looks like this:
"use strict"; module.exports = { entry: "./src/file.js", output: { filename: "./dist/bundle.js" }, devServer: { contentBase: ".", host: "localhost", port: 9000 }, module: { loaders: [ { test: /\.jsx?$/, loader: "babel-loader" } ] } };
entry
specify the entry point of our js project, in the output
indicate where to save the finished bundle.
entry
like this:
entry: { file1: "./src/file1.js", file2: "./src/file2.js" }
output
field.
output: { path: path.join(__dirname, "./dist"), filename: "[name].js" }
file1.js
at the output: file1.js
and file2.js
.
Run-Development
from Task Runner.
Run-Development
manually, we will make the webpack monitor the changes in the files. For this, it has a --watch
mode. We will launch the webpack in this mode each time the project is opened. Add a line
/// <binding ProjectOpened='Watch - Development' />
webpack.config.js
to the beginning of webpack.config.js
and you webpack.config.js
done. Yes, that simple!
npm install --save-dev webpack-notifier
webpack.config.js
file
var WebpackNotifierPlugin = require('webpack-notifier'); module.exports = { // ... plugins: [ new WebpackNotifierPlugin() ] };
Source: https://habr.com/ru/post/278103/