1 | $ npm install webpack -g |
1 | $ npm install webpack --save-dev |
1 | $ npm install webpack@1.2.x --save-dev |
1 2 | var cats = ['dave', 'henry', 'martha']; module.exports = cats; |
1 2 | cats = require('./cats.js'); console.log(cats); |
1 | webpack ./app.js app.bundle.js |
1 2 3 4 5 6 | module.exports = { entry: './main.js', output: { filename: 'bundle.js' } }; |
1 2 3 4 5 6 7 8 9 10 | module.exports = { entry: { Profile: './profile.js', Feed: './feed.js' }, output: { path: 'build', filename: '[name].js' // Template based on keys in entry above } }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | module.exports = { entry: './main.js', output: { filename: 'bundle.js' }, module: { loaders: [ { test: /\.coffee$/, loader: 'coffee-loader' }, { test: /\.js$/, loader: 'babel-loader', query: { presets: ['es2015', 'react'] } } ] }, resolve: { // you can now require('file') instead of require('file.coffee') extensions: ['', '.js', '.json', '.coffee'] } }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | module.exports = { entry: './main.js', output: { // This is where images AND js will go path: './build', // This is used to generate URLs to e.g. images publicPath: 'http://mycdn.com/', filename: 'bundle.js' }, module: { loaders: [ // use ! to chain loaders { test: /\.less$/, loader: 'style-loader!css-loader!less-loader' }, { test: /\.css$/, loader: 'style-loader!css-loader' }, // inline base64 URLs for <=8k images, direct URLs for the rest { test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192' } ] } }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 | var webpack = require('webpack'); var commonsPlugin = new webpack.optimize.CommonsChunkPlugin('common.js'); module.exports = { entry: { Profile: './profile.js', Feed: './feed.js' }, output: { path: 'build', filename: '[name].js' // Template based on keys in entry above }, plugins: [commonsPlugin] }; |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |