标签:filename xxxx class test specified resolve error: 文件 ice
cnpm i -D webpack webpack-cli
app.js
import ‘./es6‘; require(‘./common‘); require(‘./amd‘); // npx webpack app.js console.log(‘app‘);
es6.js
export default ‘es6‘; console.log(‘es6‘);
common.js
module.exports = ‘commonjs‘;
console.log(‘common-js‘);
amd.js
define(function () { console.log(‘requires-js‘) });
npx webpack app.js
// npx webpack --config xxxx-config.js const path = require(‘path‘); module.exports = { entry: { app: ‘./src/app.js‘ }, output: { path: path.join(path.resolve(__dirname), ‘dist‘), filename: "[name].bundle.[hash:8].js" }, };
npx webpack 直接就可以打包了(默认会先找项目中的webpack, 其次才是全局的webpack)
{ "name": "test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "webpack --mode=development", "build": "webpack --mode=production" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "webpack": "^4.33.0", "webpack-cli": "^3.3.2" } }
npm run dev 代码不压缩(开发环境),生产环境 npm run build,(mode 参数决定是什么环境)
标签:filename xxxx class test specified resolve error: 文件 ice
原文地址:https://www.cnblogs.com/heidekeyi/p/10989560.html