javascript - Webpack multiple entry point confusion -
from initial understanding of webpack's multiple entry point such
entry: { a: "./a", b: "./b", c: ["./c", "./d"] }, output: { path: path.join(__dirname, "dist"), filename: "[name].entry.js" } it bundle them a.entry.js, b.entry.js , c.entry.js. there no d.entry.js since it's part of c.
however @ work, these values confusing me much. why value http link , not file?
app: [ 'webpack/hot/dev-server', 'webpack-dev-server/client?http://localhost:21200', './lib/index.js' ], test: [ 'webpack/hot/dev-server', 'webpack-dev-server/client?http://localhost:21200', './test/test.js' ]
as stated in comment on question, http urls used webpack-dev-server , hotloading module. however, want ommit modules production version of bundle, since don't need hotloading , makes bundle on 10.000 lines of code (additionally!).
for personal interest of poster, here example production config (minimalistic), project of mine (called dragjs).
// file: webpack.production.babel.js import webpack 'webpack'; import path 'path'; const root_path = path.resolve('./'); export default { entry: [ path.resolve(root_path, "src/drag") ], resolve: { extensions: ["", ".js", ".scss"] }, output: { path: path.resolve(root_path, "build"), filename: "drag.min.js" }, devtool: 'source-map', module: { loaders: [ { test: /\.js$/, loader: 'babel', include: path.resolve(root_path, 'src') }, { test: /\.scss$/, loader: 'style!css!sass' } ] }, plugins: [ new webpack.optimize.uglifyjsplugin() ] }; a few things:
- i use 1 entry point, use multiple, in example
- the entry point refers js file - no webpack-dev-server production
- the config file written using ecmascript2015 (thus name
*.babel.js) - it uses sourcemaps , uglify optimization plugin
- the presets babel-loader specified in
.babelrcfile - run webpack config via
webpack -p --config ./webpack.production.babel.js
if there further questions, grateful answer them in comments.
Comments
Post a Comment