├── .appveyor.yml
├── .eslintrc.js
├── .gitignore
├── .npmignore
├── .travis.yml
├── CHANGELOG.md
├── README.md
├── README_ZH.md
├── index.js
├── libs
├── compiler.js
├── errors.js
├── loader.js
└── utils.js
├── package-lock.json
├── package.json
├── runWebpack
└── index.js
└── test
├── config
└── config.js
├── result
├── image-in-html
│ └── index.html
├── resource-attr-1
│ └── index.html
├── resource-common-1
│ └── index.html
├── resource-common-2
│ └── index.html
├── resource-copy-plugin-1
│ └── index.html
├── resource-copy-plugin-2
│ └── index.html
├── resource-copy-plugin-3
│ └── index.html
├── resource-dev
│ └── index.html
├── resource-dev1
│ └── index.html
├── resource-dev2
│ └── index.html
├── resource-dev3
│ └── index.html
├── resource-external-1
│ └── index.html
├── resource-favico-1
│ ├── favicon.ico
│ └── index.html
├── resource-favico-2
│ └── index.html
├── resource-favico-3
│ └── index.html
├── resource-favico
│ ├── favicon.ico
│ └── index.html
├── resource-inline-1
│ └── index.html
├── resource-inline-2
│ └── index.html
├── resource-inline-3
│ └── index.html
├── resource-inline-4
│ └── index.html
├── resource-inline-5
│ └── index.html
├── resource-inline-6
│ └── index.html
├── resource-inline-7
│ └── index.html
├── resource-inline-8
│ └── index.html
├── resource-md5-1
│ └── index.html
├── resource-md5-2
│ └── index.html
├── resource-md5-3
│ └── index.html
├── resource-md5-4
│ └── index.html
├── resource-md5-5
│ └── index.html
├── resource-production-1
│ ├── detail.html
│ └── index.html
├── resource-production
│ ├── detail.html
│ └── index.html
├── resource-query-1
│ └── entry.html
└── resource-remove
│ └── index.html
├── src
├── image-in-html
│ ├── google.png
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ └── webpack.config.js
├── resource-attr-1
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ └── webpack.config.js
├── resource-common-1
│ ├── detail.js
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ ├── react.js
│ │ ├── report.js
│ │ └── spinner.js
│ ├── list.js
│ └── webpack.config.js
├── resource-common-2
│ ├── detail.js
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ ├── react.js
│ │ ├── report.js
│ │ └── spinner.js
│ ├── list.js
│ └── webpack.config.js
├── resource-copy-plugin-1
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ ├── react-dom.js
│ │ └── react.js
│ └── webpack.config.js
├── resource-copy-plugin-2
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ ├── react-dom.js
│ │ └── react.js
│ └── webpack.config.js
├── resource-copy-plugin-3
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ ├── bootstrap
│ │ │ ├── bootstraplib.js
│ │ │ └── lib
│ │ │ │ ├── bootstrap.css
│ │ │ │ └── bootstrap.js
│ │ ├── react-dom.js
│ │ ├── react.js
│ │ └── react.min.js
│ └── webpack.config.js
├── resource-dev
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
├── resource-dev1
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
├── resource-dev2
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
├── resource-dev3
│ ├── index.html
│ ├── index.js
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
├── resource-external-1
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
├── resource-favico-1
│ ├── favicon.ico
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ ├── logo.png
│ └── webpack.config.js
├── resource-favico-2
│ ├── favicon.ico
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ ├── logo.png
│ └── webpack.config.js
├── resource-favico-3
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ ├── logo.png
│ └── webpack.config.js
├── resource-favico
│ ├── favicon.ico
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ ├── logo.png
│ └── webpack.config.js
├── resource-inline-1
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ └── webpack.config.js
├── resource-inline-2
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ └── webpack.config.js
├── resource-inline-3
│ ├── common.js
│ ├── detail.html
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ └── webpack.config.js
├── resource-inline-4
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ └── webpack.config.js
├── resource-inline-5
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ └── webpack.config.js
├── resource-inline-6
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ └── webpack.config.js
├── resource-inline-7
│ ├── src
│ │ ├── common
│ │ │ └── common.js
│ │ ├── css
│ │ │ └── common.css
│ │ ├── index.html
│ │ ├── index.less
│ │ └── js
│ │ │ └── index.js
│ └── webpack.config.js
├── resource-inline-8
│ ├── src
│ │ ├── common
│ │ │ └── common.js
│ │ ├── css
│ │ │ └── common.css
│ │ ├── index.html
│ │ ├── index.less
│ │ └── js
│ │ │ └── index.js
│ └── webpack.config.js
├── resource-md5-1
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
├── resource-md5-2
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
├── resource-md5-3
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
├── resource-md5-4
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
├── resource-md5-5
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
├── resource-production-1
│ ├── detail.html
│ ├── detail.js
│ ├── detail.less
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
├── resource-production
│ ├── detail.html
│ ├── detail.js
│ ├── detail.less
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
├── resource-query-1
│ ├── detail.js
│ ├── detail.less
│ ├── index.html
│ ├── index.js
│ ├── index.less
│ ├── libs
│ │ └── react.js
│ └── webpack.config.js
└── resource-remove
│ ├── index.html
│ ├── index.js
│ ├── index.json
│ ├── index.less
│ ├── index.png
│ ├── libs
│ └── react.js
│ ├── logo.png
│ └── webpack.config.js
└── test.js
/.appveyor.yml:
--------------------------------------------------------------------------------
1 | # Test against the latest version of this Node.js version
2 | environment:
3 | matrix:
4 | - nodejs_version: "6"
5 | - nodejs_version: "8"
6 | - nodejs_version: "10"
7 |
8 | # Install scripts. (runs after repo cloning)
9 | install:
10 | # Get the latest stable version of Node.js or io.js
11 | - ps: Install-Product node $env:nodejs_version
12 | # install modules
13 | - npm install
14 |
15 | # Post-install test scripts.
16 | test_script:
17 | # Output useful info for debugging.
18 | - node --version
19 | - npm --version
20 | # run tests
21 | - npm test
22 |
23 | # Don't actually build.
24 | build: off
25 |
26 | matrix:
27 | fast_finish: true
28 | cache:
29 | - node_modules -> package.json
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true,
4 | node: true,
5 | commonjs: true,
6 | es6: true
7 | },
8 | extends: 'eslint:recommended',
9 | rules: {
10 | indent: 0,
11 | 'no-extra-boolean-cast': 0,
12 | 'no-console': 0,
13 | 'no-redeclare': 1,
14 | 'one-var-declaration-per-line': [2, 'always'],
15 | 'no-mixed-spaces-and-tabs': 0,
16 | semi: 0,
17 | 'no-useless-escape': 0,
18 | 'no-control-regex': 0
19 | },
20 | globals: {
21 | describe: true,
22 | it: true
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules*
2 | dist
3 | .DS_Store
4 | .webpack_cache
5 | .vscode
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | spec
2 | specWebpack
3 | runWebpack
4 | test
5 | .vscode
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - node
5 | - 8
6 | - 6
7 | cache:
8 | directories:
9 | - node_modules
10 |
11 | script: npm run test
12 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## English
2 | - v0.0.1 resouce inline and md5
3 | - v0.0.2 customized name and hash
4 | - v0.0.3 support favicon file
5 | - v0.0.4 fix adding prefix and adding md5 bugs
6 | - v0.0.5 offer templateContent to modify html content before output
7 | - v0.0.7 compatible with webpack2.0 [README](https://github.com/lcxfs1991/html-res-webpack-plugin/blob/v0.0.7/README.md)
8 | - v1.0.0 rewrite the whole thing and add testing function
9 | - v1.0.1 allow external resource to be injected
10 | - v1.1.0 support writing assets in html
11 | - v1.1.2 print chunk name in runtime
12 | - v1.1.3 fix bug for using hot update
13 | - v1.2.0 support using loader and image in html
14 | - v1.2.2 fix bug from uglify js which remove quotes
15 | - v1.2.3 just chanage a few text
16 | - v1.2.6 add doc and test for resource attribute
17 | - v1.3.0 upgrade `copy-webpack-plugin-hash` from 3.x to 4.x
18 | - v1.3.1 fix favicon copy bug
19 | - v1.3.2 compatible with link closing tag
20 | - v1.3.3 remove inline resource
21 | - v1.3.4 fix removeing inline resource bug
22 | - v2.0.0 upgrade some dependencies and improve test cases
23 | - v2.0.1 not inline when in dev mode
24 | - v2.0.2 appending extension to chunk in resource is also supported
25 | - v2.0.3 support inline resource without webpack compilation
26 | - v2.0.4 fix xxx.min files copied by `copy-webpack-plugin-hash` issue
27 | - v3.0.0 [breaking change] for `default` or `html` mode, `extention` is needed for matching resources
28 | - v3.0.1 fix replace bug with special string $&
29 | - v3.0.2 fix hot update bug
30 | - v3.1.0 add asset production asset support; remove asset when option is set; ignore asset with http protocol
31 | - v3.1.1 support development only asset
32 | - v3.2.0 update dependency
33 | - v3.2.2 support query and hash
34 | - v3.2.3 fix children undefined array
35 | - v3.2.4 Add AppVeyor to test Windows Environment
36 | - v3.2.5 upgrade `copy-webpack-plugin-hash` and have more tests
37 | - v3.2.6 If the injected resources is not found, keep running the plugin
38 | - v4.0.1 Support webpack4.x
39 | - v4.0.2 Fix duplicate resource in watch mode
40 | - v4.0.3 fix external favico issue
41 | - v4.0.4 fix favico not exist error
42 |
43 | ## 中文
44 | - v0.0.1 html生成及相关js,css资源内联
45 | - v0.0.2 使生成的文件名和哈希可定制化
46 | - v0.0.3 支持生成favicon文件
47 | - v0.0.4 修复针对某些资源添加前缀或添加md5的错误
48 | - v0.0.5 添加templateContent函数以提供定制化修改html的办法
49 | - v0.0.7 compatible with webpack2.0 [README](https://github.com/lcxfs1991/html-res-webpack-plugin/blob/v0.0.7/README_ZH.md)
50 | - v1.0.0 重构及添加测试用例
51 | - v1.0.1 允许外部资源注入
52 | - v1.1.0 允许在html中写入资源配置
53 | - v1.1.2 在运行时打印出chunk的名字
54 | - v1.1.3 修复使用热替换时的bug
55 | - v1.2.0 支持对html使用loader以及支持image插入到html中
56 | - v1.2.2 修复uglify js引入的,去掉引号无法匹配问题
57 | - v1.2.3 改了点小文案而已
58 | - v1.2.6 给资源属性添加文档与测试用例
59 | - v1.3.0 将 `copy-webpack-plugin-hash` 从3.x 升级至 4.x
60 | - v1.3.1 修复 favicon 复制的 bug
61 | - v1.3.2 兼容link闭合写法
62 | - v1.3.3 去除inline的资源
63 | - v1.3.4 修复去除inline的资源带来的bug
64 | - v2.0.0 升级部份依赖,以及优化测试用例
65 | - v2.0.1 开发模式下,支持不内联资源
66 | - v2.0.2 支持在资源末尾添加后缀名
67 | - v2.0.3 支持内联不经webpack编译的资源
68 | - v2.0.4 修复 xxx.min 文件被 `copy-webpack-plugin-hash` 插件拷贝的问题
69 | - v3.0.0 [重大更新] 对于 `default` 或 `html` mode, `extention` (扩展名)需要用于匹配静态资源
70 | - v3.0.1 修复 replace 函数在内容带有 $& 字符串的问题
71 | - v3.0.2 修复热替换bug
72 | - v3.1.0 支持生产环境显示指定资源;允许配置去除资源;忽略带有 http 协议的资源
73 | - v3.1.1 支持仅在开发环境里出现的指定资源
74 | - v3.2.0 更新依赖
75 | - v3.2.2 支持 query 和 hash
76 | - v3.2.4 引入 AppVeyor 测试 Windows 环境
77 | - v3.2.5 升级 `copy-webpack-plugin-hash` 及做了更多测试
78 | - v3.2.6 若注入资源中,如果没有引入资源,会让程序继续运行
79 | - v4.0.1 支持 webpack4.x
80 | - v4.0.2 修复 watch 模式下资源重复的问题
81 | - v4.0.3 修复外链 favico 的问题
82 | - v4.0.4 修复 favico 文件不存在报错
83 | - v4.0.5 修复link标签和script标签中间有换行符匹配不到的问题
84 |
--------------------------------------------------------------------------------
/libs/errors.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | optionRequredErr: function(option) {
3 | console.error('html-res-webpack-plugin: ');
4 | console.error(option + ' is required');
5 | },
6 | optionChunkExtention: function(item) {
7 | console.error('html-res-webpack-plugin: ');
8 | console.error("If you use default mode, please add extension to the chunk you wanna inject.");
9 | console.error("Like " + item + ".js, " + item + ".css and so on.");
10 | },
11 | extensionRequired: function(route) {
12 | console.error('html-res-webpack-plugin: ');
13 | console.error("If you use html mode, please add extension to the resource you wanna match.");
14 | console.error("Like , and so on.");
15 | }
16 | };
--------------------------------------------------------------------------------
/libs/loader.js:
--------------------------------------------------------------------------------
1 | /* This loader renders the template with underscore if no other loader was found */
2 | 'use strict';
3 |
4 | var _ = require('lodash');
5 | var loaderUtils = require('loader-utils');
6 |
7 | module.exports = function (source) {
8 | if (this.cacheable) {
9 | this.cacheable();
10 | }
11 | var allLoadersButThisOne = this.loaders.filter(function (loader) {
12 | // Loader API changed from `loader.module` to `loader.normal` in Webpack 2.
13 | return (loader.module || loader.normal) !== module.exports;
14 | });
15 | // This loader shouldn't kick in if there is any other loader
16 | if (allLoadersButThisOne.length > 0) {
17 | return source;
18 | }
19 | // Skip .js files
20 | if (/\.js$/.test(this.request)) {
21 | return source;
22 | }
23 |
24 | // The following part renders the tempalte with lodash as aminimalistic loader
25 | //
26 | // Get templating options
27 | var options = loaderUtils.getOptions(this);
28 | // Webpack 2 does not allow with() statements, which lodash templates use to unwrap
29 | // the parameters passed to the compiled template inside the scope. We therefore
30 | // need to unwrap them ourselves here. This is essentially what lodash does internally
31 | // To tell lodash it should not use with we set a variable
32 | var template = _.template(source, _.defaults(options, { variable: 'data' }));
33 | // All templateVariables which should be available
34 | // @see HtmlWebpackPlugin.prototype.executeTemplate
35 | var templateVariables = [
36 | 'compilation',
37 | 'webpack',
38 | 'webpackConfig',
39 | 'htmlWebpackPlugin'
40 | ];
41 | return 'var _ = require(' + loaderUtils.stringifyRequest(this, require.resolve('lodash')) + ');' +
42 | 'module.exports = function (templateParams) {' +
43 | // Declare the template variables in the outer scope of the
44 | // lodash template to unwrap them
45 | templateVariables.map(function (variableName) {
46 | return 'var ' + variableName + ' = templateParams.' + variableName;
47 | }).join(';') + ';' +
48 | // Execute the lodash template
49 | 'return (' + template.source + ')();' +
50 | '}';
51 | };
52 |
--------------------------------------------------------------------------------
/libs/utils.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const path = require('path'),
4 | chalk = require('chalk');
5 |
6 | module.exports = {
7 |
8 | getFileType: (filename) => {
9 |
10 | let ext = path.extname(filename).replace(".", ""),
11 | questionMark = ext.indexOf("?");
12 |
13 | if (!!~questionMark) {
14 | ext = ext.replace(ext.substring(questionMark, ext.length), "");
15 | }
16 |
17 | return ext;
18 | },
19 |
20 | /**
21 | * [get file basename]
22 | * @param {[type]} template [模版位置]
23 | * @param {[type]} dest [目标位置]
24 | * @return {[type]} []
25 | */
26 | getBaseName: (template, dest) => {
27 | var filename = path.resolve(template);
28 | var basename = dest || path.basename(filename);
29 |
30 | return basename;
31 | },
32 |
33 | /**
34 | * [print info level message]
35 | * @param {[type]} msg [description]
36 | * @return {[type]} [description]
37 | */
38 | info: function(msg, level) {
39 | let l = level || 0;
40 | (l >= 0) && console.log(chalk.green('[html-res-webapck-plugin] ' + msg));
41 | },
42 |
43 | /**
44 | * [print info alert message]
45 | * @param {[type]} msg [description]
46 | * @return {[type]} [description]
47 | */
48 | alert: function(msg, level) {
49 | let l = level || 0;
50 | (l >= 1) && console.log(chalk.yellow('[html-res-webapck-plugin] ' + msg));
51 | }
52 | };
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "html-res-webpack-plugin",
3 | "version": "4.0.7",
4 | "description": "html generation and resource inline or md5 for webpack",
5 | "keywords": [
6 | "front-end",
7 | "web",
8 | "webpack",
9 | "plugin",
10 | "building tool"
11 | ],
12 | "homepage": "https://github.com/lcxfs1991/html-res-webpack-plugin",
13 | "bugs": {
14 | "url": "https://github.com/lcxfs1991/html-res-webpack-plugin/issues"
15 | },
16 | "repository": {
17 | "type": "git",
18 | "url": "git@github.com:lcxfs1991/html-res-webpack-plugin.git"
19 | },
20 | "author": "heyli",
21 | "files": [
22 | "bin",
23 | "libs",
24 | "index.js"
25 | ],
26 | "scripts": {
27 | "pretest": "node ./runWebpack/index.js",
28 | "lint": "eslint index.js libs",
29 | "test": "npm run lint && mocha",
30 | "travis": "npm run cover -- --report lcovonly"
31 | },
32 | "dependencies": {
33 | "bluebird": "^3.5.1",
34 | "chalk": "^2.4.1",
35 | "fs-extra": "^7.0.0",
36 | "html-minifier": "^3.5.19",
37 | "loader-utils": "^1.1.0",
38 | "lodash": "^4.17.10",
39 | "rimraf": "^2.6.1"
40 | },
41 | "devDependencies": {
42 | "async": "^2.6.1",
43 | "babel-core": "^6.26.3",
44 | "babel-loader": "^7.1.5",
45 | "babel-preset-es2015": "^6.24.1",
46 | "copy-webpack-plugin-hash": "^6.0.0",
47 | "css-loader": "^1.0.0",
48 | "eslint": "^5.2.0",
49 | "expect.js": "^0.3.1",
50 | "file-loader": "^1.1.11",
51 | "html-loader": "^0.5.5",
52 | "klaw": "^2.1.1",
53 | "less": "^3.7.1",
54 | "less-loader": "^4.1.0",
55 | "mini-css-extract-plugin": "^0.4.1",
56 | "mocha": "^5.2.0",
57 | "mocha-lcov-reporter": "^1.3.0",
58 | "sinon": "^6.1.4",
59 | "style-loader": "^0.21.0",
60 | "url-loader": "^1.0.1",
61 | "webpack": "^4.16.1",
62 | "webpack-asset-pipeline": "^1.1.1"
63 | },
64 | "peerDependencies": {
65 | "html-loader": "0.5.x"
66 | },
67 | "license": "MIT",
68 | "engines": {
69 | "node": ">=6.0.0",
70 | "npm": ">=3.0.0"
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/runWebpack/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const fs = require("fs-extra"),
4 | async = require("async"),
5 | webpack = require("webpack"),
6 | path = require("path");
7 |
8 | fs.removeSync(path.resolve("./test/dist/"));
9 |
10 | var basePath = path.resolve("./test/src/");
11 |
12 | var webpackConfig = [
13 | require(basePath + "/resource-dev/webpack.config.js"), // dev environment
14 | require(basePath + "/resource-dev1/webpack.config.js"), // html mode dev environment
15 | require(basePath + "/resource-dev2/webpack.config.js"), // html mode dev environment with extension
16 | require(basePath + "/resource-dev3/webpack.config.js"), // lack of resources
17 | require(basePath + "/resource-inline-1/webpack.config.js"), // inline without compression
18 | require(basePath + "/resource-inline-2/webpack.config.js"), // inline with compression
19 | require(basePath + "/resource-inline-3/webpack.config.js"), // html mode inline without compression
20 | require(basePath + "/resource-inline-4/webpack.config.js"), // html mode inline without compression in dev mode (not inline)
21 | require(basePath + "/resource-inline-5/webpack.config.js"), // inline without compression in dev mode
22 | require(basePath + "/resource-inline-6/webpack.config.js"), // inline without compression with extension
23 | require(basePath + "/resource-inline-7/webpack.config.js"), // inline file without webpack parse
24 | require(basePath + "/resource-inline-8/webpack.config.js"), // inline file without webpack parse special case
25 | require(basePath + "/resource-md5-1/webpack.config.js"), // md5 with compression / index chunk before react
26 | require(basePath + "/resource-md5-2/webpack.config.js"), // md5 without compression / react chunk before index
27 | require(basePath + "/resource-md5-3/webpack.config.js"), // html mode md5 without compression
28 | require(basePath + "/resource-md5-4/webpack.config.js"), // html mode md5 without quote "/'
29 | require(basePath + "/resource-md5-5/webpack.config.js"), // html mode md5 without compression with extension
30 | require(basePath + "/resource-favico/webpack.config.js"), // generate favicon
31 | require(basePath + "/resource-favico-1/webpack.config.js"), // html mode generate favicon
32 | require(basePath + "/resource-favico-2/webpack.config.js"), // html mode external favicon
33 | require(basePath + "/resource-favico-3/webpack.config.js"), // no favicon file but fill in the option
34 | require(basePath + "/resource-common-1/webpack.config.js"), // common chunk generated by webpack
35 | require(basePath + "/resource-common-2/webpack.config.js"), // html mode common chunk generated by webpack
36 | require(basePath + "/resource-copy-plugin-1/webpack.config.js"), // usage with copy-webpack-plugin-hash
37 | require(basePath + "/resource-copy-plugin-2/webpack.config.js"), // usage with copy-webpack-plugin-hash
38 | require(basePath + "/resource-copy-plugin-3/webpack.config.js"), // html mode usage with copy-webpack-plugin-hash
39 | require(basePath + "/resource-external-1/webpack.config.js"), // external resource
40 | require(basePath + "/image-in-html/webpack.config.js"), // image in html
41 | require(basePath + "/resource-attr-1/webpack.config.js"), // resource attribute
42 | require(basePath + "/resource-remove/webpack.config.js"), // remove asset if not found
43 | require(basePath + "/resource-production/webpack.config.js"), // keep asset only in production env -- production
44 | require(basePath + "/resource-production-1/webpack.config.js"), // keep asset only in production env -- development
45 | require(basePath + "/resource-query-1/webpack.config.js") // asset width query or hash
46 | ];
47 |
48 | async.filter(
49 | webpackConfig,
50 | function(configPath, callback) {
51 | let compiler = webpack(configPath);
52 | compiler.run(function(err, stats) {
53 | if (err) {
54 | console.log(err);
55 | }
56 | callback();
57 | });
58 | },
59 | function(err, results) {
60 | if (!err) {
61 | // console.log(results);
62 | } else {
63 | console.log(err);
64 | }
65 | }
66 | );
67 |
--------------------------------------------------------------------------------
/test/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const path = require('path'),
4 | __basename = path.dirname(__dirname);
5 |
6 | /**
7 | * [config basic configuration]
8 | * @type {Object}
9 | */
10 | var config = {
11 | path: {
12 | src: path.resolve(__basename, "src"),
13 | dist: path.resolve(__basename, "dist"),
14 | pub: path.resolve(__basename, "pub"),
15 | node: path.resolve(__basename, "node"),
16 | },
17 | chunkhash: "-[chunkhash:6]",
18 | hash: "-[hash:6]",
19 | contenthash: "-[contenthash:6]",
20 | defaultPath: "//localhost:9000/",
21 | cdn: "//localhost:8000/",
22 | };
23 |
24 | module.exports = config;
25 |
--------------------------------------------------------------------------------
/test/result/image-in-html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/result/resource-attr-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test/result/resource-common-1/index.html:
--------------------------------------------------------------------------------
1 | Tencent QQ
--------------------------------------------------------------------------------
/test/result/resource-common-2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/test/result/resource-copy-plugin-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/result/resource-copy-plugin-2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/result/resource-copy-plugin-3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/test/result/resource-dev/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test/result/resource-dev1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test/result/resource-dev2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/result/resource-dev3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/result/resource-external-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/result/resource-favico-1/favicon.ico:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/result/resource-favico-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/result/resource-favico-2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/result/resource-favico-3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/result/resource-favico/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/result/resource-favico/favicon.ico
--------------------------------------------------------------------------------
/test/result/resource-favico/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/result/resource-inline-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
13 |
14 |
15 |
16 |
129 |
--------------------------------------------------------------------------------
/test/result/resource-inline-2/index.html:
--------------------------------------------------------------------------------
1 | Tencent QQ
--------------------------------------------------------------------------------
/test/result/resource-inline-3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
134 |
135 |
--------------------------------------------------------------------------------
/test/result/resource-inline-4/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/test/result/resource-inline-5/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/result/resource-inline-6/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
13 |
14 |
15 |
16 |
17 |
130 |
131 |
--------------------------------------------------------------------------------
/test/result/resource-inline-7/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
123 |
124 |
--------------------------------------------------------------------------------
/test/result/resource-md5-1/index.html:
--------------------------------------------------------------------------------
1 | Tencent QQ
--------------------------------------------------------------------------------
/test/result/resource-md5-2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test/result/resource-md5-3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/result/resource-md5-4/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/test/result/resource-md5-5/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/test/result/resource-production-1/detail.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/result/resource-production-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/result/resource-production/detail.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/result/resource-production/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/result/resource-query-1/entry.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/result/resource-remove/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/test/src/image-in-html/google.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/image-in-html/google.png
--------------------------------------------------------------------------------
/test/src/image-in-html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/src/image-in-html/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/image-in-html/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/image-in-html/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require("path");
4 |
5 | var webpack = require("webpack"),
6 | config = require("../../config/config"),
7 | nodeModulesPath = path.resolve("../node_modules");
8 |
9 | var HtmlResWebpackPlugin = require("../../../index"),
10 | MiniCssExtractPlugin = require("mini-css-extract-plugin"),
11 | WebpackAssetPipeline = require("webpack-asset-pipeline");
12 |
13 | module.exports = {
14 | context: config.path.src,
15 | entry: {
16 | index: [path.join(config.path.src, "/image-in-html/index")]
17 | },
18 | output: {
19 | publicPath: config.defaultPath,
20 | path: path.join(config.path.dist + "/image-in-html/"),
21 | filename: "js/[name]" + config.chunkhash + ".js",
22 | chunkFilename: "js/chunk/[name]" + config.chunkhash + ".js"
23 | },
24 | module: {
25 | rules: [
26 | {
27 | test: /\.js?$/,
28 | loader: "babel-loader",
29 | query: {
30 | cacheDirectory: false,
31 | presets: ["es2015"]
32 | },
33 | exclude: /node_modules/
34 | },
35 | {
36 | test: /\.less$/,
37 | use: [
38 | MiniCssExtractPlugin.loader,
39 | {
40 | loader: "css-loader",
41 | options: {
42 | localIdentName: "[name]-[local]-[hash:base64:5]"
43 | }
44 | },
45 | {
46 | loader: "less-loader"
47 | }
48 | ]
49 | },
50 | {
51 | test: /\.html$/,
52 | loader: "html-loader"
53 | },
54 | {
55 | test: /\.(jpe?g|png|gif|svg)$/i,
56 | use: [
57 | "url-loader?limit=1000&name=img/[name]" +
58 | config.hash +
59 | ".[ext]"
60 | ],
61 | include: path.resolve(config.path.src)
62 | }
63 | ]
64 | },
65 | plugins: [
66 | new webpack.NoEmitOnErrorsPlugin(),
67 | new MiniCssExtractPlugin({
68 | filename: "css/[name]" + config.chunkhash + ".css"
69 | }),
70 | new HtmlResWebpackPlugin({
71 | mode: "html",
72 | filename: "index.html",
73 | template: config.path.src + "/image-in-html/index.html",
74 | htmlMinify: null
75 | }),
76 | new WebpackAssetPipeline()
77 | ]
78 | };
79 |
--------------------------------------------------------------------------------
/test/src/resource-attr-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test/src/resource-attr-1/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-attr-1/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-attr-1/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
11 | WebpackAssetPipeline = require('webpack-asset-pipeline');
12 |
13 | module.exports = {
14 | context: config.path.src,
15 | entry: {
16 | index: [path.join(config.path.src, "/resource-attr-1/index")]
17 | },
18 | output: {
19 | publicPath: config.defaultPath,
20 | path: path.join(config.path.dist + '/resource-attr-1/'),
21 | filename: "js/[name]" + config.chunkhash + ".js",
22 | chunkFilename: "js/chunk/[name]" + config.chunkhash + ".js",
23 | },
24 | module: {
25 | rules: [
26 | {
27 | test: /\.js?$/,
28 | loader: 'babel-loader',
29 | query: {
30 | cacheDirectory: false,
31 | presets: [
32 | 'es2015',
33 | ]
34 | },
35 | exclude: /node_modules/,
36 | },
37 | {
38 | test: /\.less$/,
39 | use: [
40 | MiniCssExtractPlugin.loader,
41 | {
42 | loader: 'css-loader',
43 | options: {
44 | localIdentName: '[name]-[local]-[hash:base64:5]',
45 | }
46 | },
47 | {
48 | loader: 'less-loader',
49 | }
50 | ],
51 | },
52 | {
53 | test: /\.html$/,
54 | loader: 'html-loader'
55 | },
56 | {
57 | test: /\.(jpe?g|png|gif|svg)$/i,
58 | use: [
59 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
60 | ],
61 | include: path.resolve(config.path.src)
62 | },
63 | ],
64 | },
65 | plugins: [
66 | new webpack.NoEmitOnErrorsPlugin(),
67 | new MiniCssExtractPlugin("css/[name]" + config.chunkhash + ".css"),
68 | new HtmlResWebpackPlugin({
69 | mode: "html",
70 | filename: "index.html",
71 | template: config.path.src + "/resource-attr-1/index.html",
72 | htmlMinify: null
73 | }),
74 | new WebpackAssetPipeline(),
75 | ],
76 | };
--------------------------------------------------------------------------------
/test/src/resource-common-1/detail.js:
--------------------------------------------------------------------------------
1 |
2 | var report = require("./libs/report");
3 | var spin = require("./libs/spinner");
4 |
5 | var b = "hey man!";
--------------------------------------------------------------------------------
/test/src/resource-common-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/src/resource-common-1/index.js:
--------------------------------------------------------------------------------
1 | var report = require("./libs/report");
2 | var spin = require("./libs/spinner");
3 |
4 | require('./index.less');
5 |
6 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-common-1/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-common-1/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-common-1/libs/report.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | report: function() {
3 | console.log("report");
4 | }
5 | }
--------------------------------------------------------------------------------
/test/src/resource-common-1/libs/spinner.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | spin1: true,
3 | spin2: false,
4 | };
--------------------------------------------------------------------------------
/test/src/resource-common-1/list.js:
--------------------------------------------------------------------------------
1 |
2 | var report = require("./libs/report");
3 | var spin = require("./libs/spinner");
4 |
5 | var b = "hey list!";
--------------------------------------------------------------------------------
/test/src/resource-common-1/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require("path");
4 |
5 | var webpack = require("webpack"),
6 | config = require("../../config/config"),
7 | nodeModulesPath = path.resolve("../node_modules");
8 |
9 | var HtmlResWebpackPlugin = require("../../../index"),
10 | MiniCssExtractPlugin = require("mini-css-extract-plugin"),
11 | WebpackAssetPipeline = require("webpack-asset-pipeline");
12 |
13 | module.exports = {
14 | context: config.path.src,
15 | entry: {
16 | "js/index": [path.join(config.path.src, "/resource-common-1/index")],
17 | "js/detail": [path.join(config.path.src, "/resource-common-1/detail")],
18 | "js/list": [path.join(config.path.src, "/resource-common-1/list")],
19 | "libs/react": [path.join(config.path.src, "/resource-common-1/libs/react")]
20 | },
21 | output: {
22 | publicPath: config.defaultPath,
23 | path: path.join(config.path.dist + "/resource-common-1/"),
24 | filename: "[name]" + config.chunkhash + ".js",
25 | chunkFilename: "chunk/[name]" + config.chunkhash + ".js"
26 | },
27 | module: {
28 | rules: [
29 | {
30 | test: /\.js?$/,
31 | loader: "babel-loader",
32 | query: {
33 | cacheDirectory: false,
34 | presets: ["es2015"]
35 | },
36 | exclude: /node_modules/
37 | },
38 | {
39 | test: /\.less$/,
40 | use: [
41 | MiniCssExtractPlugin.loader,
42 | {
43 | loader: "css-loader",
44 | options: {
45 | localIdentName: "[name]-[local]-[hash:base64:5]"
46 | }
47 | },
48 | {
49 | loader: "less-loader"
50 | }
51 | ]
52 | },
53 | {
54 | test: /\.html$/,
55 | loader: "html-loader"
56 | },
57 | {
58 | test: /\.(jpe?g|png|gif|svg)$/i,
59 | use: ["url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]"],
60 | include: path.resolve(config.path.src)
61 | }
62 | ]
63 | },
64 | optimization: {
65 | splitChunks: {
66 | cacheGroups: {
67 | commons: {
68 | test: /\.js$/,
69 | name: "commons",
70 | chunks: "all",
71 | minChunks: 1,
72 | enforce: true
73 | }
74 | }
75 | }
76 | },
77 | plugins: [
78 | new webpack.NoEmitOnErrorsPlugin(),
79 | new MiniCssExtractPlugin({
80 | filename: "css/[name]" + config.chunkhash + ".css"
81 | }),
82 | new HtmlResWebpackPlugin({
83 | filename: "index.html",
84 | template: config.path.src + "/resource-common-1/index.html",
85 | chunks: [
86 | "libs/react.js",
87 | "commons.js",
88 | "js/index.js",
89 | "js/index.css",
90 | "js/detail.js",
91 | "js/list.js"
92 | ],
93 | templateContent: function(tpl) {
94 | // 生产环境不作处理
95 | if (!this.webpackOptions.watch) {
96 | return tpl;
97 | }
98 | // 开发环境先去掉外链react.js
99 | var regex = new RegExp(
100 | "",
101 | "ig"
102 | );
103 | tpl = tpl.replace(regex, function(script, route) {
104 | if (
105 | !!~script.indexOf("react.js") ||
106 | !!~script.indexOf("react-dom.js")
107 | ) {
108 | return "";
109 | }
110 | return script;
111 | });
112 | return tpl;
113 | },
114 | htmlMinify: {
115 | removeComments: true,
116 | collapseWhitespace: true
117 | }
118 | }),
119 | new WebpackAssetPipeline()
120 | ]
121 | };
122 |
--------------------------------------------------------------------------------
/test/src/resource-common-2/detail.js:
--------------------------------------------------------------------------------
1 |
2 | var report = require("./libs/report");
3 | var spin = require("./libs/spinner");
4 |
5 | var b = "hey man!";
--------------------------------------------------------------------------------
/test/src/resource-common-2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/test/src/resource-common-2/index.js:
--------------------------------------------------------------------------------
1 | var report = require("./libs/report");
2 | var spin = require("./libs/spinner");
3 |
4 | require('./index.less');
5 |
6 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-common-2/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-common-2/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-common-2/libs/report.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | report: function() {
3 | console.log("report");
4 | }
5 | }
--------------------------------------------------------------------------------
/test/src/resource-common-2/libs/spinner.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | spin1: true,
3 | spin2: false,
4 | };
--------------------------------------------------------------------------------
/test/src/resource-common-2/list.js:
--------------------------------------------------------------------------------
1 |
2 | var report = require("./libs/report");
3 | var spin = require("./libs/spinner");
4 |
5 | var b = "hey list!";
--------------------------------------------------------------------------------
/test/src/resource-common-2/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const path = require('path');
3 |
4 | var webpack = require('webpack'),
5 | config = require('../../config/config'),
6 | nodeModulesPath = path.resolve('../node_modules');
7 |
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
11 | WebpackAssetPipeline = require('webpack-asset-pipeline');
12 |
13 | module.exports = {
14 | context: config.path.src,
15 | entry: {
16 | 'js/index': [path.join(config.path.src, "/resource-common-2/index")],
17 | 'js/detail': [path.join(config.path.src, "/resource-common-2/detail")],
18 | 'js/list': [path.join(config.path.src, "/resource-common-2/list")],
19 | 'libs/react': [path.join(config.path.src, "/resource-common-2/libs/react")],
20 | },
21 | output: {
22 | publicPath: config.defaultPath,
23 | path: path.join(config.path.dist + '/resource-common-2/'),
24 | filename: "[name]" + config.chunkhash + ".js",
25 | chunkFilename: "chunk/[name]" + config.chunkhash + ".js",
26 | },
27 | module: {
28 | rules: [
29 | {
30 | test: /\.js?$/,
31 | loader: 'babel-loader',
32 | query: {
33 | cacheDirectory: false,
34 | presets: [
35 | 'es2015',
36 | ]
37 | },
38 | exclude: /node_modules/,
39 | },
40 | {
41 | test: /\.less$/,
42 | use: [
43 | MiniCssExtractPlugin.loader,
44 | {
45 | loader: 'css-loader',
46 | options: {
47 | localIdentName: '[name]-[local]-[hash:base64:5]',
48 | }
49 | },
50 | {
51 | loader: 'less-loader',
52 | }
53 | ],
54 | },
55 | {
56 | test: /\.html$/,
57 | loader: 'html-loader'
58 | },
59 | {
60 | test: /\.(jpe?g|png|gif|svg)$/i,
61 | use: [
62 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
63 | ],
64 | include: path.resolve(config.path.src)
65 | },
66 | ]
67 | },
68 | optimization: {
69 | splitChunks: {
70 | cacheGroups: {
71 | common: {
72 | chunks: 'all',
73 | minChunks: 1,
74 | test: /\.js$/,
75 | name: 'commons',
76 | enforce: true
77 | }
78 | }
79 | }
80 | },
81 | plugins: [
82 | new webpack.NoEmitOnErrorsPlugin(),
83 | new MiniCssExtractPlugin({filename: "css/[name]-[contenthash:6].css"}),
84 | // TODO: remove code
85 | // new webpack.optimize.CommonsChunkPlugin({
86 | // name: "commons",
87 | // // (the commons chunk name)
88 |
89 | // filename: "js/commons-[hash:6].js",
90 | // // (the filename of the commons chunk)
91 |
92 | // // minChunks: 3,
93 | // // (Modules must be shared between 3 entries)
94 |
95 | // // chunks: ["pageA", "pageB"],
96 | // // (Only use these entries)
97 | // }),
98 | new HtmlResWebpackPlugin({
99 | mode: "html",
100 | filename: "index.html",
101 | template: config.path.src + "/resource-common-2/index.html",
102 | htmlMinify: {
103 | // removeComments: true,
104 | // collapseWhitespace: true,
105 | }
106 | }),
107 | new WebpackAssetPipeline(),
108 | ],
109 | };
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-1/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-1/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-1/libs/react-dom.js:
--------------------------------------------------------------------------------
1 | /**
2 | * ReactDOM v15.1.0
3 | *
4 | * Copyright 2013-present, Facebook, Inc.
5 | * All rights reserved.
6 | *
7 | * This source code is licensed under the BSD-style license found in the
8 | * LICENSE file in the root directory of this source tree. An additional grant
9 | * of patent rights can be found in the PATENTS file in the same directory.
10 | *
11 | */
12 | !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var f;f="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,f.ReactDOM=e(f.React)}}(function(e){return e.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED});
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-1/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules'),
8 | fs = require('fs');
9 |
10 |
11 | var HtmlResWebpackPlugin = require('../../../index'),
12 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
13 | CopyWebpackPlugin = require('copy-webpack-plugin-hash'),
14 | WebpackAssetPipeline = require('webpack-asset-pipeline');
15 |
16 |
17 | function CopyAssetPlugin() {
18 |
19 | }
20 |
21 | CopyAssetPlugin.prototype.apply = function(compiler) {
22 | compiler.hooks.afterEmit.tap('HtmlResWebpackPlugin', (compilation) => {
23 | let assets = compilation.assets,
24 | copyAssets = Object.keys(assets),
25 | assetChunk = [];
26 |
27 | copyAssets.forEach((file) => {
28 | if (assets[file].chunk) {
29 | assetChunk.push(file);
30 | }
31 | });
32 |
33 | let manifest = path.join(config.path.dist, "/resource-copy-plugin-1/manifest.json");
34 |
35 | let assetObject = JSON.parse(fs.readFileSync(manifest, "utf-8") || "");
36 |
37 | assetChunk.forEach((file) => {
38 | assetObject[assets[file].chunk] = file;
39 | });
40 |
41 | fs.writeFileSync(manifest, JSON.stringify(assetObject, null, 4), "utf-8");
42 | });
43 | };
44 |
45 | module.exports = {
46 | context: config.path.src,
47 | entry: {
48 | // 'libs/react': [path.join(config.path.src, "/resource-copy-plugin/libs/react")],
49 | 'js/index': [path.join(config.path.src, "/resource-copy-plugin-1/index")],
50 | },
51 | output: {
52 | publicPath: config.defaultPath,
53 | path: path.join(config.path.dist + '/resource-copy-plugin-1/'),
54 | filename: "[name]" + config.chunkhash + ".js",
55 | chunkFilename: "chunk/[name]" + config.chunkhash + ".js",
56 | },
57 | module: {
58 | rules: [
59 | {
60 | test: /\.js?$/,
61 | loader: 'babel-loader',
62 | query: {
63 | cacheDirectory: false,
64 | presets: [
65 | 'es2015',
66 | ]
67 | },
68 | exclude: /node_modules/,
69 | },
70 | {
71 | test: /\.less$/,
72 | use: [
73 | MiniCssExtractPlugin.loader,
74 | {
75 | loader: 'css-loader',
76 | options: {
77 | localIdentName: '[name]-[local]-[hash:base64:5]',
78 | }
79 | },
80 | {
81 | loader: 'less-loader',
82 | }
83 | ],
84 | },
85 | {
86 | test: /\.html$/,
87 | loader: 'html-loader'
88 | },
89 | {
90 | test: /\.(jpe?g|png|gif|svg)$/i,
91 | use: [
92 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
93 | ],
94 | include: path.resolve(config.path.src)
95 | },
96 | ]
97 | },
98 | plugins: [
99 | new webpack.NoEmitOnErrorsPlugin(),
100 | new MiniCssExtractPlugin({filename: "css/[name]-[contenthash:6].css"}),
101 | new CopyWebpackPlugin([
102 | {
103 | from: config.path.src + '/resource-copy-plugin-1/libs/',
104 | to: 'libs/[name]' + config.hash + '.[ext]'
105 | }
106 | ]),
107 | new HtmlResWebpackPlugin({
108 | filename: "index.html",
109 | template: config.path.src + "/resource-copy-plugin-1/index.html",
110 | chunks:[
111 | 'libs/react.js',
112 | 'libs/react-dom.js',
113 | 'js/index.js',
114 | 'js/index.css',
115 | ],
116 | templateContent: function(tpl) {
117 | // 生产环境不作处理
118 | if (!this.webpackOptions.watch) {
119 | return tpl;
120 | }
121 | // 开发环境先去掉外链react.js
122 | var regex = new RegExp("<\/script>", "ig");
123 | tpl = tpl.replace(regex, function(script, route) {
124 | if (!!~script.indexOf('react.js') || !!~script.indexOf('react-dom.js')) {
125 | return '';
126 | }
127 | return script;
128 | });
129 | return tpl;
130 | },
131 | htmlMinify: null
132 | }),
133 | new WebpackAssetPipeline(),
134 | new CopyAssetPlugin(),
135 | ],
136 | };
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-2/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-2/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-2/libs/react-dom.js:
--------------------------------------------------------------------------------
1 | /**
2 | * ReactDOM v15.1.0
3 | *
4 | * Copyright 2013-present, Facebook, Inc.
5 | * All rights reserved.
6 | *
7 | * This source code is licensed under the BSD-style license found in the
8 | * LICENSE file in the root directory of this source tree. An additional grant
9 | * of patent rights can be found in the PATENTS file in the same directory.
10 | *
11 | */
12 | !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var f;f="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,f.ReactDOM=e(f.React)}}(function(e){return e.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED});
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-2/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules'),
8 | fs = require('fs');
9 |
10 |
11 | var HtmlResWebpackPlugin = require('../../../index'),
12 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
13 | CopyWebpackPlugin = require('copy-webpack-plugin-hash'),
14 | WebpackAssetPipeline = require('webpack-asset-pipeline');
15 |
16 | function CopyAssetPlugin() {
17 |
18 | }
19 |
20 | CopyAssetPlugin.prototype.apply = function(compiler) {
21 | compiler.hooks.afterEmit.tap('HtmlResWebpackPlugin', (compilation) => {
22 | let assets = compilation.assets,
23 | copyAssets = Object.keys(assets),
24 | assetChunk = [];
25 |
26 | copyAssets.forEach((file) => {
27 | if (assets[file].chunk) {
28 | assetChunk.push(file);
29 | }
30 | });
31 |
32 | let manifest = path.join(config.path.dist, "/resource-copy-plugin-2/manifest.json");
33 |
34 | let assetObject = JSON.parse(fs.readFileSync(manifest, "utf-8") || "");
35 |
36 | assetChunk.forEach((file) => {
37 | assetObject[assets[file].chunk] = file;
38 | });
39 |
40 | fs.writeFileSync(manifest, JSON.stringify(assetObject, null, 4), "utf-8");
41 | });
42 | };
43 |
44 | module.exports = {
45 | context: config.path.src,
46 | entry: {
47 | 'js/index': [path.join(config.path.src, "/resource-copy-plugin-2/index")],
48 | },
49 | output: {
50 | publicPath: config.defaultPath,
51 | path: path.join(config.path.dist + '/resource-copy-plugin-2/'),
52 | filename: "[name]" + config.chunkhash + ".js",
53 | chunkFilename: "chunk/[name]" + config.chunkhash + ".js",
54 | },
55 | module: {
56 | rules: [
57 | {
58 | test: /\.js?$/,
59 | loader: 'babel-loader',
60 | query: {
61 | cacheDirectory: false,
62 | presets: [
63 | 'es2015',
64 | ]
65 | },
66 | exclude: /node_modules/,
67 | },
68 | {
69 | test: /\.less$/,
70 | use: [
71 | MiniCssExtractPlugin.loader,
72 | {
73 | loader: 'css-loader',
74 | options: {
75 | localIdentName: '[name]-[local]-[hash:base64:5]',
76 | }
77 | },
78 | {
79 | loader: 'less-loader',
80 | }
81 | ],
82 | },
83 | {
84 | test: /\.html$/,
85 | loader: 'html-loader'
86 | },
87 | {
88 | test: /\.(jpe?g|png|gif|svg)$/i,
89 | use: [
90 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
91 | ],
92 | include: path.resolve(config.path.src)
93 | },
94 | ],
95 | },
96 | plugins: [
97 | new webpack.NoEmitOnErrorsPlugin(),
98 | new MiniCssExtractPlugin({filename: "css/[name]-[contenthash:6].css"}),
99 | new CopyWebpackPlugin([
100 | {
101 | from: config.path.src + '/resource-copy-plugin-2/libs/',
102 | to: 'libs/[name]' + config.hash + '.[ext]'
103 | }
104 | ]),
105 | new HtmlResWebpackPlugin({
106 | filename: "index.html",
107 | template: config.path.src + "/resource-copy-plugin-2/index.html",
108 | chunks:{
109 | 'libs/react.js': {
110 | attr: "async=\"true\"",
111 | },
112 | 'libs/react-dom.js': null,
113 | 'js/index.js': null,
114 | 'js/index.css': null,
115 | },
116 | templateContent: function(tpl) {
117 | // 生产环境不作处理
118 | if (!this.webpackOptions.watch) {
119 | return tpl;
120 | }
121 | // 开发环境先去掉外链react.js
122 | var regex = new RegExp("<\/script>", "ig");
123 | tpl = tpl.replace(regex, function(script, route) {
124 | if (!!~script.indexOf('react.js') || !!~script.indexOf('react-dom.js')) {
125 | return '';
126 | }
127 | return script;
128 | });
129 | return tpl;
130 | },
131 | htmlMinify: null
132 | }),
133 | new WebpackAssetPipeline(),
134 | new CopyAssetPlugin(),
135 | ],
136 | };
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-3/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-3/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-3/libs/bootstrap/bootstraplib.js:
--------------------------------------------------------------------------------
1 | console.log("bootstraplib");
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-3/libs/bootstrap/lib/bootstrap.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | width: 100%;
5 | height: 100%;
6 | }
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-3/libs/bootstrap/lib/bootstrap.js:
--------------------------------------------------------------------------------
1 | console.log("bootstrap");
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-3/libs/react-dom.js:
--------------------------------------------------------------------------------
1 | /**
2 | * ReactDOM v15.1.0
3 | *
4 | * Copyright 2013-present, Facebook, Inc.
5 | * All rights reserved.
6 | *
7 | * This source code is licensed under the BSD-style license found in the
8 | * LICENSE file in the root directory of this source tree. An additional grant
9 | * of patent rights can be found in the PATENTS file in the same directory.
10 | *
11 | */
12 | !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var f;f="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,f.ReactDOM=e(f.React)}}(function(e){return e.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED});
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-3/libs/react.min.js:
--------------------------------------------------------------------------------
1 | console.log('react.min');
--------------------------------------------------------------------------------
/test/src/resource-copy-plugin-3/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require("path");
4 |
5 | var webpack = require("webpack"),
6 | config = require("../../config/config"),
7 | nodeModulesPath = path.resolve("../node_modules"),
8 | fs = require("fs");
9 |
10 | var HtmlResWebpackPlugin = require("../../../index"),
11 | MiniCssExtractPlugin = require("mini-css-extract-plugin"),
12 | CopyWebpackPlugin = require("copy-webpack-plugin-hash"),
13 | WebpackAssetPipeline = require("webpack-asset-pipeline");
14 |
15 | function CopyAssetPlugin() {}
16 |
17 | CopyAssetPlugin.prototype.apply = function(compiler) {
18 | compiler.hooks.afterEmit.tap("CopyAssetPlugin", compilation => {
19 | let assets = compilation.assets,
20 | copyAssets = Object.keys(assets),
21 | assetChunk = [];
22 |
23 | copyAssets.forEach(file => {
24 | if (assets[file].chunk) {
25 | assetChunk.push(file);
26 | }
27 | });
28 |
29 | let manifest = path.join(
30 | config.path.dist,
31 | "/resource-copy-plugin-3/manifest.json"
32 | );
33 |
34 | let assetObject = JSON.parse(fs.readFileSync(manifest, "utf-8") || "");
35 |
36 | assetChunk.forEach(file => {
37 | assetObject[assets[file].chunk] = file;
38 | });
39 |
40 | fs.writeFileSync(
41 | manifest,
42 | JSON.stringify(assetObject, null, 4),
43 | "utf-8"
44 | );
45 | });
46 | };
47 |
48 | module.exports = {
49 | context: config.path.src,
50 | entry: {
51 | "js/index": [
52 | path.join(config.path.src, "/resource-copy-plugin-3/index")
53 | ]
54 | },
55 | output: {
56 | publicPath: config.defaultPath,
57 | path: path.join(config.path.dist + "/resource-copy-plugin-3/"),
58 | filename: "[name]" + config.chunkhash + ".js",
59 | chunkFilename: "chunk/[name]" + config.chunkhash + ".js"
60 | },
61 | module: {
62 | rules: [
63 | {
64 | test: /\.js?$/,
65 | loader: "babel-loader",
66 | query: {
67 | cacheDirectory: false,
68 | presets: ["es2015"]
69 | },
70 | exclude: /node_modules/
71 | },
72 | {
73 | test: /\.less$/,
74 | use: [
75 | MiniCssExtractPlugin.loader,
76 | {
77 | loader: "css-loader",
78 | options: {
79 | localIdentName: "[name]-[local]-[hash:base64:5]"
80 | }
81 | },
82 | {
83 | loader: "less-loader"
84 | }
85 | ]
86 | },
87 | {
88 | test: /\.html$/,
89 | loader: "html-loader"
90 | },
91 | {
92 | test: /\.(jpe?g|png|gif|svg)$/i,
93 | use: [
94 | "url-loader?limit=1000&name=img/[name]" +
95 | config.hash +
96 | ".[ext]"
97 | ],
98 | include: path.resolve(config.path.src)
99 | }
100 | ]
101 | },
102 | plugins: [
103 | new webpack.NoEmitOnErrorsPlugin(),
104 | new MiniCssExtractPlugin({
105 | filename: "css/[name]-[contenthash:6].css"
106 | }),
107 | new CopyWebpackPlugin([
108 | {
109 | from: config.path.src + "/resource-copy-plugin-3/libs/",
110 | to: "libs/[path][name]" + config.hash + ".[ext]"
111 | }
112 | ]),
113 | new HtmlResWebpackPlugin({
114 | mode: "html",
115 | entryLog: true,
116 | filename: "index.html",
117 | template: config.path.src + "/resource-copy-plugin-3/index.html",
118 | templateContent: function(tpl) {
119 | // 生产环境不作处理
120 | if (!this.webpackOptions.watch) {
121 | return tpl;
122 | }
123 | // 开发环境先去掉外链react.js
124 | var regex = new RegExp(
125 | "",
126 | "ig"
127 | );
128 | tpl = tpl.replace(regex, function(script, route) {
129 | if (
130 | !!~script.indexOf("react.js") ||
131 | !!~script.indexOf("react-dom.js")
132 | ) {
133 | return "";
134 | }
135 | return script;
136 | });
137 | return tpl;
138 | },
139 | htmlMinify: null
140 | }),
141 | new WebpackAssetPipeline(),
142 | new CopyAssetPlugin()
143 | ]
144 | };
145 |
--------------------------------------------------------------------------------
/test/src/resource-dev/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/src/resource-dev/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | import './index.less';
4 |
5 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-dev/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-dev/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-dev/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require("path");
4 |
5 | var webpack = require("webpack"),
6 | config = require("../../config/config"),
7 | nodeModulesPath = path.resolve("../node_modules");
8 |
9 | var HtmlResWebpackPlugin = require("../../../index"),
10 | MiniCssExtractPlugin = require("mini-css-extract-plugin");
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | "libs/react": [path.join(config.path.src, "/resource-dev/libs/react")],
16 | "js/index": [path.join(config.path.src, "/resource-dev/index")]
17 | },
18 | output: {
19 | publicPath: config.defaultPath,
20 | path: path.join(config.path.dist + "/resource-dev/"),
21 | filename: "[name].js",
22 | chunkFilename: "chunk/[name].js"
23 | },
24 | module: {
25 | rules: [
26 | {
27 | test: /\.js?$/,
28 | loader: "babel-loader",
29 | options: {
30 | // verbose: false,
31 | cacheDirectory: "./.webpack_cache/",
32 | presets: [["es2015", { loose: true }]]
33 | },
34 | exclude: /node_modules/
35 | },
36 | {
37 | test: /\.less$/,
38 | use: [
39 | MiniCssExtractPlugin.loader,
40 | {
41 | loader: "css-loader",
42 | options: {
43 | localIdentName: "[name]-[local]-[hash:base64:5]"
44 | }
45 | },
46 | "less-loader"
47 | ]
48 | },
49 | {
50 | test: /\.html$/,
51 | loader: "html-loader"
52 | },
53 | {
54 | test: /\.(jpe?g|png|gif|svg)$/i,
55 | use: ["url-loader?limit=1000&name=img/[name].[ext]"],
56 | include: path.resolve(config.path.src)
57 | }
58 | ]
59 | },
60 | plugins: [
61 | new webpack.NoEmitOnErrorsPlugin(),
62 | new MiniCssExtractPlugin({
63 | filename: "css/[name].css"
64 | }),
65 | new HtmlResWebpackPlugin({
66 | filename: "html/entry.html",
67 | template: config.path.src + "/resource-dev/index.html",
68 | chunks: {
69 | "libs/react.js": null,
70 | "js/index.js": {
71 | attr: ""
72 | },
73 | "js/index.css": {
74 | attr: "offline"
75 | }
76 | },
77 | templateContent: function(tpl) {
78 | // 生产环境不作处理
79 | if (!this.webpackOptions.watch) {
80 | return tpl;
81 | }
82 | // 开发环境先去掉外链react.js
83 | var regex = new RegExp(
84 | "",
85 | "ig"
86 | );
87 | tpl = tpl.replace(regex, function(script, route) {
88 | if (
89 | !!~script.indexOf("react.js") ||
90 | !!~script.indexOf("react-dom.js")
91 | ) {
92 | return "";
93 | }
94 | return script;
95 | });
96 | return tpl;
97 | },
98 | htmlMinify: null
99 | })
100 | ],
101 | resolve: {
102 | modules: [config.path.src, "node_modules"],
103 | extensions: [
104 | ".js",
105 | ".jsx",
106 | ".css",
107 | ".scss",
108 | ".less",
109 | ".styl",
110 | ".png",
111 | ".jpg",
112 | ".jpeg",
113 | ".ico",
114 | ".ejs",
115 | ".pug",
116 | ".handlebars",
117 | "swf"
118 | ],
119 | alias: {}
120 | }
121 | // watch: true,
122 | };
123 |
--------------------------------------------------------------------------------
/test/src/resource-dev1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test/src/resource-dev1/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-dev1/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-dev1/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-dev1/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | 'libs/react': [path.join(config.path.src, "/resource-dev1/libs/react")],
16 | 'index': [path.join(config.path.src, "/resource-dev1/index")],
17 | },
18 | output: {
19 | publicPath: config.defaultPath,
20 | path: path.join(config.path.dist + '/resource-dev1/'),
21 | filename: "js/[name].js",
22 | chunkFilename: "chunk/[name].js",
23 | },
24 | module: {
25 | rules: [
26 | {
27 | test: /\.js?$/,
28 | loader: 'babel-loader',
29 | query: {
30 | cacheDirectory: false,
31 | presets: [
32 | 'es2015',
33 | ]
34 | },
35 | exclude: /node_modules/,
36 | },
37 | {
38 | test: /\.less$/,
39 | use: [
40 | MiniCssExtractPlugin.loader,
41 | {
42 | loader: 'css-loader',
43 | options: {
44 | localIdentName: '[name]-[local]-[hash:base64:5]',
45 | }
46 | },
47 | {
48 | loader: 'less-loader',
49 | }
50 | ]
51 | },
52 | {
53 | test: /\.html$/,
54 | loader: 'html-loader'
55 | },
56 | {
57 | test: /\.(jpe?g|png|gif|svg)$/i,
58 | use: [
59 | "url-loader?limit=1000&name=img/[name].[ext]",
60 | ],
61 | include: path.resolve(config.path.src)
62 | },
63 | ],
64 | },
65 | plugins: [
66 | new webpack.NoEmitOnErrorsPlugin(),
67 | new MiniCssExtractPlugin({
68 | filename: "css/[name].css",
69 | publicPath: "//localhost:1111/",
70 | }),
71 | new HtmlResWebpackPlugin({
72 | mode: 'html',
73 | filename: "html/entry.html",
74 | template: config.path.src + "/resource-dev1/index.html",
75 | cssPublicPath: "//localhost:1111/",
76 | htmlMinify: null
77 | })
78 | ],
79 | watch: true,
80 | };
--------------------------------------------------------------------------------
/test/src/resource-dev2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/src/resource-dev2/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-dev2/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-dev2/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-dev2/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | 'libs/react': [path.join(config.path.src, "/resource-dev2/libs/react")],
16 | 'index': [path.join(config.path.src, "/resource-dev2/index")],
17 | },
18 | output: {
19 | publicPath: config.defaultPath,
20 | path: path.join(config.path.dist + '/resource-dev2/'),
21 | filename: "js/[name].js",
22 | chunkFilename: "chunk/[name].js",
23 | },
24 | module: {
25 | rules: [
26 | {
27 | test: /\.js?$/,
28 | loader: 'babel-loader',
29 | query: {
30 | cacheDirectory: false,
31 | presets: [
32 | 'es2015',
33 | ]
34 | },
35 | exclude: /node_modules/,
36 | },
37 | {
38 | test: /\.less$/,
39 | use: [
40 | MiniCssExtractPlugin.loader,
41 | {
42 | loader: 'css-loader',
43 | options: {
44 | localIdentName: '[name]-[local]-[hash:base64:5]',
45 | }
46 | },
47 | {
48 | loader: 'less-loader',
49 | }
50 | ],
51 | },
52 | {
53 | test: /\.html$/,
54 | loader: 'html-loader'
55 | },
56 | {
57 | test: /\.(jpe?g|png|gif|svg)$/i,
58 | use: [
59 | "url-loader?limit=1000&name=img/[name].[ext]",
60 | ],
61 | include: path.resolve(config.path.src)
62 | },
63 | ],
64 | },
65 | plugins: [
66 | new webpack.NoEmitOnErrorsPlugin(),
67 | new MiniCssExtractPlugin({
68 | filename: "css/[name].css",
69 | publicPath: "//localhost:1111/",
70 | }),
71 | new HtmlResWebpackPlugin({
72 | mode: 'html',
73 | filename: "html/entry.html",
74 | template: config.path.src + "/resource-dev2/index.html",
75 | cssPublicPath: "//localhost:1111/",
76 | htmlMinify: null
77 | })
78 | ],
79 | watch: true,
80 | };
--------------------------------------------------------------------------------
/test/src/resource-dev3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/src/resource-dev3/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-dev3/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-dev3/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | 'libs/react': [path.join(config.path.src, "/resource-dev3/libs/react")],
16 | 'js/index': [path.join(config.path.src, "/resource-dev3/index")],
17 | },
18 | output: {
19 | publicPath: config.defaultPath,
20 | path: path.join(config.path.dist + '/resource-dev3/'),
21 | filename: "[name].js",
22 | chunkFilename: "chunk/[name].js",
23 | },
24 | module: {
25 | rules: [
26 | {
27 | test: /\.js?$/,
28 | loader: 'babel-loader',
29 | options: {
30 | // verbose: false,
31 | cacheDirectory: './.webpack_cache/',
32 | presets: [
33 | ["es2015", {"loose": true}],
34 | ]
35 | },
36 | exclude: /node_modules/,
37 | },
38 | {
39 | test: /\.less$/,
40 | use: [
41 | MiniCssExtractPlugin.loader,
42 | {
43 | loader: 'css-loader',
44 | options: {
45 | localIdentName: '[name]-[local]-[hash:base64:5]',
46 | }
47 | },
48 | {
49 | loader: 'less-loader',
50 | }
51 | ],
52 | },
53 | {
54 | test: /\.html$/,
55 | loader: 'html-loader'
56 | },
57 | {
58 | test: /\.(jpe?g|png|gif|svg)$/i,
59 | use: [
60 | "url-loader?limit=1000&name=img/[name].[ext]",
61 | ],
62 | include: path.resolve(config.path.src)
63 | },
64 | ]
65 | },
66 | plugins: [
67 | new webpack.NoEmitOnErrorsPlugin(),
68 | new MiniCssExtractPlugin({ filename: "css/[name].css"}),
69 | new HtmlResWebpackPlugin({
70 | filename: "html/entry.html",
71 | template: config.path.src + "/resource-dev3/index.html",
72 | chunks:{
73 | 'libs/react.js': null,
74 | 'js/index.js': {
75 | attr: ""
76 | },
77 | 'js/index.css': {
78 | attr: "offline",
79 | },
80 | },
81 | templateContent: function(tpl) {
82 | // 生产环境不作处理
83 | if (!this.webpackOptions.watch) {
84 | return tpl;
85 | }
86 | // 开发环境先去掉外链react.js
87 | var regex = new RegExp("<\/script>", "ig");
88 | tpl = tpl.replace(regex, function(script, route) {
89 | if (!!~script.indexOf('react.js') || !!~script.indexOf('react-dom.js')) {
90 | return '';
91 | }
92 | return script;
93 | });
94 | return tpl;
95 | },
96 | htmlMinify: null
97 | })
98 | ],
99 | resolve: {
100 | modules: [
101 | config.path.src,
102 | "node_modules",
103 | ],
104 | extensions: [".js", ".jsx", ".css", ".scss", ".less", ".styl", ".png", ".jpg", ".jpeg", ".ico", ".ejs", ".pug", ".handlebars", "swf"],
105 | alias: {}
106 | },
107 | // watch: true,
108 | };
--------------------------------------------------------------------------------
/test/src/resource-external-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/src/resource-external-1/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-external-1/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-external-1/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-external-1/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 |
10 | var HtmlResWebpackPlugin = require('../../../index'),
11 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
12 | WebpackAssetPipeline = require('webpack-asset-pipeline');
13 |
14 | module.exports = {
15 | context: config.path.src,
16 | entry: {
17 | 'js/index': [path.join(config.path.src, "/resource-external-1/index")],
18 | 'libs/react': [path.join(config.path.src, "/resource-external-1/libs/react")],
19 | },
20 | output: {
21 | publicPath: config.defaultPath,
22 | path: path.join(config.path.dist + '/resource-external-1/'),
23 | filename: "[name]" + config.chunkhash + ".js",
24 | chunkFilename: "chunk/[name]" + config.chunkhash + ".js",
25 | },
26 | module: {
27 | rules: [
28 | {
29 | test: /\.js?$/,
30 | loader: 'babel-loader',
31 | query: {
32 | cacheDirectory: false,
33 | presets: [
34 | 'es2015',
35 | ]
36 | },
37 | exclude: /node_modules/,
38 | },
39 | {
40 | test: /\.less$/,
41 | use: [
42 | MiniCssExtractPlugin.loader,
43 | {
44 | loader: 'css-loader',
45 | options: {
46 | localIdentName: '[name]-[local]-[hash:base64:5]',
47 | }
48 | },
49 | {
50 | loader: 'less-loader',
51 | }
52 | ],
53 | },
54 | {
55 | test: /\.html$/,
56 | loader: 'html-loader'
57 | },
58 | {
59 | test: /\.(jpe?g|png|gif|svg)$/i,
60 | use: [
61 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
62 | ],
63 | include: path.resolve(config.path.src)
64 | },
65 | ]
66 | },
67 | plugins: [
68 | new webpack.NoEmitOnErrorsPlugin(),
69 | new MiniCssExtractPlugin({filename: "css/[name]-[contenthash:6].css"}),
70 | new HtmlResWebpackPlugin({
71 | filename: "index.html",
72 | template: config.path.src + "/resource-external-1/index.html",
73 | chunks:{
74 | 'common.css': {
75 | external: true,
76 | res: "//s.url.cn/common.css",
77 | attr: "offline"
78 | },
79 | 'libs/react.js': null,
80 | 'qreport.js': {
81 | external: true,
82 | res: "//s.url.cn/pub/js/qreport.js?_bid=2231",
83 | attr: "async=\"true\"",
84 | },
85 | 'js/index.js': null,
86 | 'js/index.css': null,
87 | },
88 | templateContent: function(tpl) {
89 | // 生产环境不作处理
90 | if (!this.webpackOptions.watch) {
91 | return tpl;
92 | }
93 | // 开发环境先去掉外链react.js
94 | var regex = new RegExp("<\/script>", "ig");
95 | tpl = tpl.replace(regex, function(script, route) {
96 | if (!!~script.indexOf('react.js') || !!~script.indexOf('react-dom.js')) {
97 | return '';
98 | }
99 | return script;
100 | });
101 | return tpl;
102 | },
103 | }),
104 | new WebpackAssetPipeline(),
105 | ],
106 | };
--------------------------------------------------------------------------------
/test/src/resource-favico-1/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-favico-1/favicon.ico
--------------------------------------------------------------------------------
/test/src/resource-favico-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/src/resource-favico-1/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-favico-1/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | .img {
7 | background-url: url("./logo.png");
8 | }
--------------------------------------------------------------------------------
/test/src/resource-favico-1/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-favico-1/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-favico-1/logo.png
--------------------------------------------------------------------------------
/test/src/resource-favico-1/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 |
10 | var HtmlResWebpackPlugin = require('../../../index'),
11 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
12 | WebpackAssetPipeline = require('webpack-asset-pipeline');
13 |
14 | module.exports = {
15 | context: config.path.src,
16 | entry: {
17 | 'libs/react': [path.join(config.path.src, "/resource-favico-1/libs/react")],
18 | 'js/index': [path.join(config.path.src, "/resource-favico-1/index")],
19 | },
20 | output: {
21 | publicPath: config.defaultPath,
22 | path: path.join(config.path.dist + '/resource-favico-1/'),
23 | filename: "[name]" + config.chunkhash + ".js",
24 | chunkFilename: "chunk/[name]" + config.chunkhash + ".js",
25 | },
26 | module: {
27 | rules: [
28 | {
29 | test: /\.js?$/,
30 | loader: 'babel-loader',
31 | query: {
32 | cacheDirectory: false,
33 | presets: [
34 | 'es2015',
35 | ]
36 | },
37 | exclude: /node_modules/,
38 | },
39 | {
40 | test: /\.less$/,
41 | use: [
42 | MiniCssExtractPlugin.loader,
43 | {
44 | loader: 'css-loader',
45 | options: {
46 | localIdentName: '[name]-[local]-[hash:base64:5]',
47 | }
48 | },
49 | {
50 | loader: 'less-loader',
51 | }
52 | ],
53 | },
54 | {
55 | test: /\.html$/,
56 | loader: 'html-loader'
57 | },
58 | {
59 | test: /\.(jpe?g|png|gif|svg)$/i,
60 | use: [
61 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
62 | ],
63 | include: path.resolve(config.path.src)
64 | },
65 | ]
66 | },
67 | plugins: [
68 | new webpack.NoEmitOnErrorsPlugin(),
69 | new MiniCssExtractPlugin({filename: "css/[name]-[contenthash:6].css"}),
70 | new HtmlResWebpackPlugin({
71 | mode: "html",
72 | filename: "index.html",
73 | template: config.path.src + "/resource-favico-1/index.html",
74 | favicon: config.path.src + "/resource-favico-1/favicon.ico",
75 | templateContent: function(tpl) {
76 | return tpl;
77 | },
78 | htmlMinify: null
79 | }),
80 | new WebpackAssetPipeline(),
81 | ],
82 | };
--------------------------------------------------------------------------------
/test/src/resource-favico-2/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-favico-2/favicon.ico
--------------------------------------------------------------------------------
/test/src/resource-favico-2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/src/resource-favico-2/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-favico-2/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | .img {
7 | background-url: url("./logo.png");
8 | }
--------------------------------------------------------------------------------
/test/src/resource-favico-2/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-favico-2/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-favico-2/logo.png
--------------------------------------------------------------------------------
/test/src/resource-favico-2/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 |
10 | var HtmlResWebpackPlugin = require('../../../index'),
11 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
12 | WebpackAssetPipeline = require('webpack-asset-pipeline');
13 |
14 | module.exports = {
15 | context: config.path.src,
16 | entry: {
17 | 'libs/react': [path.join(config.path.src, "/resource-favico-2/libs/react")],
18 | 'js/index': [path.join(config.path.src, "/resource-favico-2/index")],
19 | },
20 | output: {
21 | publicPath: config.defaultPath,
22 | path: path.join(config.path.dist + '/resource-favico-2/'),
23 | filename: "[name]" + config.chunkhash + ".js",
24 | chunkFilename: "chunk/[name]" + config.chunkhash + ".js",
25 | },
26 | module: {
27 | rules: [
28 | {
29 | test: /\.js?$/,
30 | loader: 'babel-loader',
31 | query: {
32 | cacheDirectory: false,
33 | presets: [
34 | 'es2015',
35 | ]
36 | },
37 | exclude: /node_modules/,
38 | },
39 | {
40 | test: /\.less$/,
41 | use: [
42 | MiniCssExtractPlugin.loader,
43 | {
44 | loader: 'css-loader',
45 | options: {
46 | localIdentName: '[name]-[local]-[hash:base64:5]',
47 | }
48 | },
49 | {
50 | loader: 'less-loader',
51 | }
52 | ],
53 | },
54 | {
55 | test: /\.html$/,
56 | loader: 'html-loader'
57 | },
58 | {
59 | test: /\.(jpe?g|png|gif|svg)$/i,
60 | use: [
61 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
62 | ],
63 | include: path.resolve(config.path.src)
64 | },
65 | ]
66 | },
67 | plugins: [
68 | new webpack.NoEmitOnErrorsPlugin(),
69 | new MiniCssExtractPlugin({filename: "css/[name]-[contenthash:6].css"}),
70 | new HtmlResWebpackPlugin({
71 | mode: "html",
72 | filename: "index.html",
73 | template: config.path.src + "/resource-favico-2/index.html",
74 | favicon: config.path.src + "/resource-favico-2/favicon.ico",
75 | templateContent: function(tpl) {
76 | return tpl;
77 | },
78 | htmlMinify: null
79 | }),
80 | new WebpackAssetPipeline(),
81 | ],
82 | };
--------------------------------------------------------------------------------
/test/src/resource-favico-3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/src/resource-favico-3/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-favico-3/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | .img {
7 | background-url: url("./logo.png");
8 | }
--------------------------------------------------------------------------------
/test/src/resource-favico-3/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-favico-3/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-favico-3/logo.png
--------------------------------------------------------------------------------
/test/src/resource-favico-3/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | let webpack = require('webpack');
6 | let config = require('../../config/config');
7 | let nodeModulesPath = path.resolve('../node_modules');
8 |
9 | let HtmlResWebpackPlugin = require('../../../index');
10 | let MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 | let WebpackAssetPipeline = require('webpack-asset-pipeline');
12 |
13 | module.exports = {
14 | context: config.path.src,
15 | entry: {
16 | 'libs/react': [path.join(config.path.src, "/resource-favico-3/libs/react")],
17 | 'js/index': [path.join(config.path.src, "/resource-favico-3/index")],
18 | },
19 | output: {
20 | publicPath: config.defaultPath,
21 | path: path.join(config.path.dist + '/resource-favico-3/'),
22 | filename: "[name]" + config.chunkhash + ".js",
23 | chunkFilename: "chunk/[name]" + config.chunkhash + ".js",
24 | },
25 | module: {
26 | rules: [
27 | {
28 | test: /\.js?$/,
29 | loader: 'babel-loader',
30 | query: {
31 | cacheDirectory: false,
32 | presets: [
33 | 'es2015',
34 | ]
35 | },
36 | exclude: /node_modules/,
37 | },
38 | {
39 | test: /\.less$/,
40 | use: [
41 | MiniCssExtractPlugin.loader,
42 | {
43 | loader: 'css-loader',
44 | options: {
45 | localIdentName: '[name]-[local]-[hash:base64:5]',
46 | }
47 | },
48 | {
49 | loader: 'less-loader',
50 | }
51 | ],
52 | },
53 | {
54 | test: /\.html$/,
55 | loader: 'html-loader'
56 | },
57 | {
58 | test: /\.(jpe?g|png|gif|svg)$/i,
59 | use: [
60 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
61 | ],
62 | include: path.resolve(config.path.src)
63 | },
64 | ]
65 | },
66 | plugins: [
67 | new webpack.NoEmitOnErrorsPlugin(),
68 | new MiniCssExtractPlugin({filename: "css/[name]-[contenthash:6].css"}),
69 | new HtmlResWebpackPlugin({
70 | mode: "html",
71 | filename: "index.html",
72 | template: config.path.src + "/resource-favico-3/index.html",
73 | favicon: config.path.src + "/resource-favico-3/favicon.ico",
74 | templateContent: function(tpl) {
75 | return tpl;
76 | },
77 | htmlMinify: null
78 | }),
79 | new WebpackAssetPipeline(),
80 | ],
81 | };
--------------------------------------------------------------------------------
/test/src/resource-favico/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-favico/favicon.ico
--------------------------------------------------------------------------------
/test/src/resource-favico/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/src/resource-favico/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-favico/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | .img {
7 | background-url: url("./logo.png");
8 | }
--------------------------------------------------------------------------------
/test/src/resource-favico/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-favico/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-favico/logo.png
--------------------------------------------------------------------------------
/test/src/resource-favico/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 |
10 | var HtmlResWebpackPlugin = require('../../../index'),
11 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
12 | WebpackAssetPipeline = require('webpack-asset-pipeline');
13 |
14 | module.exports = {
15 | context: config.path.src,
16 | entry: {
17 | 'libs/react': [path.join(config.path.src, "/resource-favico/libs/react")],
18 | 'js/index': [path.join(config.path.src, "/resource-favico/index")],
19 | },
20 | output: {
21 | publicPath: config.defaultPath,
22 | path: path.join(config.path.dist + '/resource-favico/'),
23 | filename: "[name]" + config.chunkhash + ".js",
24 | chunkFilename: "chunk/[name]" + config.chunkhash + ".js",
25 | },
26 | module: {
27 | rules: [
28 | {
29 | test: /\.js?$/,
30 | loader: 'babel-loader',
31 | query: {
32 | cacheDirectory: false,
33 | presets: [
34 | 'es2015',
35 | ]
36 | },
37 | exclude: /node_modules/,
38 | },
39 | {
40 | test: /\.less$/,
41 | use: [
42 | MiniCssExtractPlugin.loader,
43 | {
44 | loader: 'css-loader',
45 | options: {
46 | localIdentName: '[name]-[local]-[hash:base64:5]',
47 | }
48 | },
49 | {
50 | loader: 'less-loader',
51 | }
52 | ],
53 | },
54 | {
55 | test: /\.html$/,
56 | loader: 'html-loader'
57 | },
58 | {
59 | test: /\.(jpe?g|png|gif|svg)$/i,
60 | use: [
61 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
62 | ],
63 | include: path.resolve(config.path.src)
64 | },
65 | ],
66 | },
67 | plugins: [
68 | new webpack.NoEmitOnErrorsPlugin(),
69 | new MiniCssExtractPlugin({filename: "css/[name]-[contenthash:6].css"}),
70 | new HtmlResWebpackPlugin({
71 | filename: "index.html",
72 | template: config.path.src + "/resource-favico/index.html",
73 | favicon: config.path.src + "/resource-favico/favicon.ico",
74 | chunks:[
75 | 'libs/react.js',
76 | 'js/index.js',
77 | 'js/index.css',
78 | ],
79 | templateContent: function(tpl) {
80 | return tpl;
81 | },
82 | htmlMinify: null
83 | }),
84 | new WebpackAssetPipeline(),
85 | ],
86 | };
--------------------------------------------------------------------------------
/test/src/resource-inline-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/src/resource-inline-1/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('../resource-md5-1/index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-inline-1/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-inline-1/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | index: [path.join(config.path.src, "/resource-inline-1/index")]
16 | },
17 | output: {
18 | publicPath: config.defaultPath,
19 | path: path.join(config.path.dist + '/resource-inline-1/'),
20 | filename: "js/[name]" + config.chunkhash + ".js",
21 | chunkFilename: "js/chunk/[name]" + config.chunkhash + ".js",
22 | },
23 | module: {
24 | rules: [
25 | {
26 | test: /\.js?$/,
27 | loader: 'babel-loader',
28 | query: {
29 | cacheDirectory: false,
30 | presets: [
31 | 'es2015',
32 | ]
33 | },
34 | exclude: /node_modules/,
35 | },
36 | {
37 | test: /\.less$/,
38 | use: [
39 | MiniCssExtractPlugin.loader,
40 | {
41 | loader: 'css-loader',
42 | options: {
43 | localIdentName: '[name]-[local]-[hash:base64:5]',
44 | }
45 | },
46 | {
47 | loader: 'less-loader',
48 | }
49 | ],
50 | },
51 | {
52 | test: /\.html$/,
53 | loader: 'html-loader'
54 | },
55 | {
56 | test: /\.(jpe?g|png|gif|svg)$/i,
57 | use: [
58 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
59 | ],
60 | include: path.resolve(config.path.src)
61 | },
62 | ]
63 | },
64 | plugins: [
65 | new webpack.NoEmitOnErrorsPlugin(),
66 | new MiniCssExtractPlugin({filename: "css/[name]" + config.chunkhash + ".css"}),
67 | new HtmlResWebpackPlugin({
68 | filename: "index.html",
69 | template: config.path.src + "/resource-inline-1/index.html",
70 | chunks:{
71 | 'index.js': {
72 | attr: "async=\"true\"",
73 | inline: true
74 | },
75 | 'index.css': {
76 | attr: "offline",
77 | inline: true
78 | }
79 | },
80 | htmlMinify: null
81 | })
82 | ],
83 | optimization: {
84 | minimize: false
85 | }
86 | };
--------------------------------------------------------------------------------
/test/src/resource-inline-2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/src/resource-inline-2/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('../resource-md5-1/index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-inline-2/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-inline-2/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | index: [path.join(config.path.src, "/resource-inline-2/index")]
16 | },
17 | output: {
18 | publicPath: config.defaultPath,
19 | path: path.join(config.path.dist + '/resource-inline-2/'),
20 | filename: "js/[name]" + config.chunkhash + ".js",
21 | chunkFilename: "js/chunk/[name]" + config.chunkhash + ".js",
22 | },
23 | module: {
24 | rules: [
25 | {
26 | test: /\.js?$/,
27 | loader: 'babel-loader',
28 | query: {
29 | cacheDirectory: false,
30 | presets: [
31 | 'es2015',
32 | ]
33 | },
34 | exclude: /node_modules/,
35 | },
36 | {
37 | test: /\.less$/,
38 | use: [
39 | MiniCssExtractPlugin.loader,
40 | {
41 | loader: 'css-loader',
42 | options: {
43 | localIdentName: '[name]-[local]-[hash:base64:5]',
44 | }
45 | },
46 | {
47 | loader: 'less-loader',
48 | }
49 | ],
50 | },
51 | {
52 | test: /\.html$/,
53 | loader: 'html-loader'
54 | },
55 | {
56 | test: /\.(jpe?g|png|gif|svg)$/i,
57 | use: [
58 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
59 | ],
60 | include: path.resolve(config.path.src)
61 | },
62 | ]
63 | },
64 | plugins: [
65 | new webpack.NoEmitOnErrorsPlugin(),
66 | new MiniCssExtractPlugin({filename: "css/[name]" + config.chunkhash + ".css"}),
67 | new HtmlResWebpackPlugin({
68 | filename: "index.html",
69 | template: config.path.src + "/resource-inline-2/index.html",
70 | chunks:{
71 | 'index.js': {
72 | attr: "async=\"true\"",
73 | inline: true
74 | },
75 | 'index.css': {
76 | attr: "offline",
77 | inline: true
78 | }
79 | },
80 | htmlMinify: {
81 | removeComments: true,
82 | collapseWhitespace: true,
83 | }
84 | })
85 | ],
86 | optimization: {
87 | minimize: false
88 | }
89 | };
--------------------------------------------------------------------------------
/test/src/resource-inline-3/common.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-inline-3/common.js
--------------------------------------------------------------------------------
/test/src/resource-inline-3/detail.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/src/resource-inline-3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/src/resource-inline-3/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('../resource-md5-1/index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-inline-3/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-inline-3/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require("path");
4 |
5 | var webpack = require("webpack"),
6 | config = require("../../config/config"),
7 | nodeModulesPath = path.resolve("../node_modules");
8 |
9 | var HtmlResWebpackPlugin = require("../../../index"),
10 | MiniCssExtractPlugin = require("mini-css-extract-plugin");
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | index: [path.join(config.path.src, "/resource-inline-3/index")],
16 | common: [path.join(config.path.src, "/resource-inline-3/common")]
17 | },
18 | output: {
19 | publicPath: config.defaultPath,
20 | path: path.join(config.path.dist, "resource-inline-3/"),
21 | filename: "js/[name]" + config.chunkhash + ".js",
22 | chunkFilename: "js/chunk/[name]" + config.chunkhash + ".js"
23 | },
24 | module: {
25 | rules: [
26 | {
27 | test: /\.js?$/,
28 | loader: "babel-loader",
29 | query: {
30 | cacheDirectory: false,
31 | presets: ["es2015"]
32 | },
33 | exclude: /node_modules/
34 | },
35 | {
36 | test: /\.less$/,
37 | use: [
38 | MiniCssExtractPlugin.loader,
39 | {
40 | loader: "css-loader",
41 | options: {
42 | localIdentName: "[name]-[local]-[hash:base64:5]"
43 | }
44 | },
45 | {
46 | loader: "less-loader"
47 | }
48 | ]
49 | },
50 | {
51 | test: /\.html$/,
52 | loader: "html-loader"
53 | },
54 | {
55 | test: /\.(jpe?g|png|gif|svg)$/i,
56 | use: [
57 | "url-loader?limit=1000&name=img/[name]" +
58 | config.hash +
59 | ".[ext]"
60 | ],
61 | include: path.resolve(config.path.src)
62 | }
63 | ]
64 | },
65 | plugins: [
66 | new webpack.NoEmitOnErrorsPlugin(),
67 | new MiniCssExtractPlugin({
68 | filename: "[name].css",
69 | chunkFilename: "[id].css"
70 | }),
71 | new HtmlResWebpackPlugin({
72 | mode: "html",
73 | filename: "index.html",
74 | template: config.path.src + "/resource-inline-3/index.html",
75 | }),
76 | new HtmlResWebpackPlugin({
77 | mode: "html",
78 | filename: "detail.html",
79 | template: config.path.src + "/resource-inline-3/detail.html",
80 | })
81 | ],
82 | optimization: {
83 | minimize: false
84 | }
85 | };
86 |
--------------------------------------------------------------------------------
/test/src/resource-inline-4/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/test/src/resource-inline-4/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-inline-4/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-inline-4/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | index: [path.join(config.path.src, "/resource-inline-4/index")],
16 | },
17 | output: {
18 | publicPath: config.defaultPath,
19 | path: path.join(config.path.dist + '/resource-inline-4/'),
20 | filename: "js/[name].js",
21 | chunkFilename: "js/chunk/[name].js",
22 | },
23 | module: {
24 | rules: [
25 | {
26 | test: /\.js?$/,
27 | loader: 'babel-loader',
28 | query: {
29 | cacheDirectory: false,
30 | presets: [
31 | 'es2015',
32 | ]
33 | },
34 | exclude: /node_modules/,
35 | },
36 | {
37 | test: /\.less$/,
38 | use: [
39 | MiniCssExtractPlugin.loader,
40 | {
41 | loader: 'css-loader',
42 | options: {
43 | localIdentName: '[name]-[local]-[hash:base64:5]',
44 | }
45 | },
46 | {
47 | loader: 'less-loader',
48 | }
49 | ],
50 | },
51 | {
52 | test: /\.html$/,
53 | loader: 'html-loader'
54 | },
55 | {
56 | test: /\.(jpe?g|png|gif|svg)$/i,
57 | use: [
58 | "url-loader?limit=1000&name=img/[name].[ext]",
59 | ],
60 | include: path.resolve(config.path.src)
61 | },
62 | ],
63 | },
64 | plugins: [
65 | new webpack.NoEmitOnErrorsPlugin(),
66 | new MiniCssExtractPlugin({ filename: "css/[name].css"}),
67 | new HtmlResWebpackPlugin({
68 | mode: "html",
69 | env: "development",
70 | filename: "index.html",
71 | template: config.path.src + "/resource-inline-4/index.html",
72 | }),
73 | ],
74 | };
--------------------------------------------------------------------------------
/test/src/resource-inline-5/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/src/resource-inline-5/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-inline-5/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-inline-5/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | index: [path.join(config.path.src, "/resource-inline-5/index")]
16 | },
17 | output: {
18 | publicPath: config.defaultPath,
19 | path: path.join(config.path.dist + '/resource-inline-5/'),
20 | filename: "js/[name].js",
21 | chunkFilename: "js/chunk/[name].js",
22 | },
23 | module: {
24 | rules: [
25 | {
26 | test: /\.js?$/,
27 | loader: 'babel-loader',
28 | query: {
29 | cacheDirectory: false,
30 | presets: [
31 | 'es2015',
32 | ]
33 | },
34 | exclude: /node_modules/,
35 | },
36 | {
37 | test: /\.less$/,
38 | use: [
39 | MiniCssExtractPlugin.loader,
40 | {
41 | loader: 'css-loader',
42 | options: {
43 | localIdentName: '[name]-[local]-[hash:base64:5]',
44 | }
45 | },
46 | {
47 | loader: 'less-loader',
48 | }
49 | ],
50 | },
51 | {
52 | test: /\.html$/,
53 | loader: 'html-loader'
54 | },
55 | {
56 | test: /\.(jpe?g|png|gif|svg)$/i,
57 | use: [
58 | "url-loader?limit=1000&name=img/[name].[ext]",
59 | ],
60 | include: path.resolve(config.path.src)
61 | },
62 | ]
63 | },
64 | plugins: [
65 | new webpack.NoEmitOnErrorsPlugin(),
66 | new MiniCssExtractPlugin({ filename: "css/[name].css"}),
67 | new HtmlResWebpackPlugin({
68 | filename: "index.html",
69 | env: "development",
70 | template: config.path.src + "/resource-inline-5/index.html",
71 | chunks:{
72 | 'index.js': {
73 | attr: "async=\"true\"",
74 | inline: true,
75 | },
76 | 'index.css': {
77 | attr: "offline",
78 | inline: true
79 | }
80 | },
81 | htmlMinify: null
82 | })
83 | ],
84 | };
--------------------------------------------------------------------------------
/test/src/resource-inline-6/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/src/resource-inline-6/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('../resource-md5-1/index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-inline-6/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-inline-6/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | index: [path.join(config.path.src, "/resource-inline-6/index")],
16 | },
17 | output: {
18 | publicPath: config.defaultPath,
19 | path: path.join(config.path.dist + '/resource-inline-6/'),
20 | filename: "js/[name]" + config.chunkhash + ".js",
21 | chunkFilename: "js/chunk/[name]" + config.chunkhash + ".js",
22 | },
23 | module: {
24 | rules: [
25 | {
26 | test: /\.js?$/,
27 | loader: 'babel-loader',
28 | query: {
29 | cacheDirectory: false,
30 | presets: [
31 | 'es2015',
32 | ]
33 | },
34 | exclude: /node_modules/,
35 | },
36 | {
37 | test: /\.less$/,
38 | use: [
39 | MiniCssExtractPlugin.loader,
40 | {
41 | loader: 'css-loader',
42 | options: {
43 | localIdentName: '[name]-[local]-[hash:base64:5]',
44 | }
45 | },
46 | {
47 | loader: 'less-loader',
48 | }
49 | ],
50 | },
51 | {
52 | test: /\.html$/,
53 | loader: 'html-loader'
54 | },
55 | {
56 | test: /\.(jpe?g|png|gif|svg)$/i,
57 | use: [
58 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
59 | ],
60 | include: path.resolve(config.path.src)
61 | },
62 | ],
63 | },
64 | plugins: [
65 | new webpack.NoEmitOnErrorsPlugin(),
66 | new MiniCssExtractPlugin({filename: "css/[name]" + config.chunkhash + ".css"}),
67 | new HtmlResWebpackPlugin({
68 | mode: "html",
69 | filename: "index.html",
70 | template: config.path.src + "/resource-inline-6/index.html",
71 | }),
72 | ],
73 | optimization: {
74 | minimize: false
75 | }
76 | };
--------------------------------------------------------------------------------
/test/src/resource-inline-7/src/common/common.js:
--------------------------------------------------------------------------------
1 | console.log('common');
--------------------------------------------------------------------------------
/test/src/resource-inline-7/src/css/common.css:
--------------------------------------------------------------------------------
1 | .reset {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-inline-7/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/src/resource-inline-7/src/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-inline-7/src/js/index.js:
--------------------------------------------------------------------------------
1 | // require('../index.less');
2 |
3 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-inline-7/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | index: [path.join(config.path.src, "/resource-inline-7/src/js/index")],
16 | },
17 | output: {
18 | publicPath: config.defaultPath,
19 | path: path.join(config.path.dist + '/resource-inline-7/'),
20 | filename: "js/[name]" + config.chunkhash + ".js",
21 | chunkFilename: "js/chunk/[name]" + config.chunkhash + ".js",
22 | },
23 | module: {
24 | rules: [
25 | {
26 | test: /\.js?$/,
27 | loader: 'babel-loader',
28 | query: {
29 | cacheDirectory: false,
30 | presets: [
31 | 'es2015',
32 | ]
33 | },
34 | exclude: /node_modules/,
35 | },
36 | {
37 | test: /\.less$/,
38 | use: [
39 | MiniCssExtractPlugin.loader,
40 | {
41 | loader: 'css-loader',
42 | options: {
43 | localIdentName: '[name]-[local]-[hash:base64:5]',
44 | }
45 | },
46 | {
47 | loader: 'less-loader',
48 | }
49 | ],
50 | },
51 | {
52 | test: /\.html$/,
53 | loader: 'html-loader'
54 | },
55 | {
56 | test: /\.(jpe?g|png|gif|svg)$/i,
57 | use: [
58 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
59 | ],
60 | include: path.resolve(config.path.src)
61 | },
62 | ],
63 | },
64 | plugins: [
65 | new webpack.NoEmitOnErrorsPlugin(),
66 | new MiniCssExtractPlugin({filename: "css/[name]" + config.chunkhash + ".css"}),
67 | new HtmlResWebpackPlugin({
68 | mode: "html",
69 | filename: "index.html",
70 | template: config.path.src + "/resource-inline-7/src/index.html",
71 | templateContent: function(tpl) {
72 | // 生产环境不作处理
73 | if (!this.webpackOptions.watch) {
74 | return tpl;
75 | }
76 | // 开发环境先去掉外链react.js
77 | var regex = new RegExp("<\/script>", "ig");
78 | tpl = tpl.replace(regex, function(script, route) {
79 | if (!!~script.indexOf('react.js') || !!~script.indexOf('react-dom.js')) {
80 | return '';
81 | }
82 | return script;
83 | });
84 | return tpl;
85 | },
86 | })
87 | ],
88 | optimization: {
89 | minimize: false
90 | }
91 | };
--------------------------------------------------------------------------------
/test/src/resource-inline-8/src/common/common.js:
--------------------------------------------------------------------------------
1 | console.log('common');
--------------------------------------------------------------------------------
/test/src/resource-inline-8/src/css/common.css:
--------------------------------------------------------------------------------
1 | .reset {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-inline-8/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/src/resource-inline-8/src/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-inline-8/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | index: [path.join(config.path.src, "/resource-inline-8/src/js/index")],
16 | },
17 | output: {
18 | publicPath: config.defaultPath,
19 | path: path.join(config.path.dist + '/resource-inline-8/'),
20 | filename: "js/[name]" + config.chunkhash + ".js",
21 | chunkFilename: "js/chunk/[name]" + config.chunkhash + ".js",
22 | },
23 | module: {
24 | rules: [
25 | {
26 | test: /\.js?$/,
27 | loader: 'babel-loader',
28 | query: {
29 | cacheDirectory: false,
30 | presets: [
31 | 'es2015',
32 | ]
33 | },
34 | exclude: /node_modules/,
35 | },
36 | {
37 | test: /\.less$/,
38 | use: [
39 | MiniCssExtractPlugin.loader,
40 | {
41 | loader: 'css-loader',
42 | options: {
43 | localIdentName: '[name]-[local]-[hash:base64:5]',
44 | }
45 | },
46 | {
47 | loader: 'less-loader',
48 | }
49 | ],
50 | },
51 | {
52 | test: /\.html$/,
53 | loader: 'html-loader'
54 | },
55 | {
56 | test: /\.(jpe?g|png|gif|svg)$/i,
57 | use: [
58 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
59 | ],
60 | include: path.resolve(config.path.src)
61 | },
62 | ],
63 | },
64 | plugins: [
65 | new webpack.NoEmitOnErrorsPlugin(),
66 | new MiniCssExtractPlugin({
67 | filename: "css/[name]" + config.chunkhash + ".css"
68 | }),
69 | new HtmlResWebpackPlugin({
70 | mode: "html",
71 | filename: "index.html",
72 | template: config.path.src + "/resource-inline-8/src/index.html",
73 | templateContent: function(tpl) {
74 | // 生产环境不作处理
75 | if (!this.webpackOptions.watch) {
76 | return tpl;
77 | }
78 | // 开发环境先去掉外链react.js
79 | var regex = new RegExp("<\/script>", "ig");
80 | tpl = tpl.replace(regex, function(script, route) {
81 | if (!!~script.indexOf('react.js') || !!~script.indexOf('react-dom.js')) {
82 | return '';
83 | }
84 | return script;
85 | });
86 | return tpl;
87 | },
88 | })
89 | ],
90 | optimization: {
91 | minimize: false
92 | }
93 | };
--------------------------------------------------------------------------------
/test/src/resource-md5-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/src/resource-md5-1/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-md5-1/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-md5-1/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-md5-1/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 |
10 | var HtmlResWebpackPlugin = require('../../../index'),
11 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
12 | WebpackAssetPipeline = require('webpack-asset-pipeline');
13 |
14 | module.exports = {
15 | context: config.path.src,
16 | entry: {
17 | 'js/index': [path.join(config.path.src, "/resource-md5-1/index")],
18 | 'libs/react': [path.join(config.path.src, "/resource-md5-1/libs/react")],
19 | },
20 | output: {
21 | publicPath: config.defaultPath,
22 | path: path.join(config.path.dist + '/resource-md5-1/'),
23 | filename: "[name]" + config.chunkhash + ".js",
24 | chunkFilename: "chunk/[name]" + config.chunkhash + ".js",
25 | },
26 | module: {
27 | rules: [
28 | {
29 | test: /\.js?$/,
30 | loader: 'babel-loader',
31 | query: {
32 | cacheDirectory: false,
33 | presets: [
34 | 'es2015',
35 | ]
36 | },
37 | exclude: /node_modules/,
38 | },
39 | {
40 | test: /\.less$/,
41 | use: [
42 | MiniCssExtractPlugin.loader,
43 | {
44 | loader: 'css-loader',
45 | options: {
46 | localIdentName: '[name]-[local]-[hash:base64:5]',
47 | }
48 | },
49 | {
50 | loader: 'less-loader',
51 | }
52 | ],
53 | },
54 | {
55 | test: /\.html$/,
56 | loader: 'html-loader'
57 | },
58 | {
59 | test: /\.(jpe?g|png|gif|svg)$/i,
60 | use: [
61 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
62 | ],
63 | include: path.resolve(config.path.src)
64 | },
65 | ],
66 | },
67 | plugins: [
68 | new webpack.NoEmitOnErrorsPlugin(),
69 | new MiniCssExtractPlugin({filename: "css/[name]-[contenthash:6].css"}),
70 | new HtmlResWebpackPlugin({
71 | filename: "index.html",
72 | template: config.path.src + "/resource-md5-1/index.html",
73 | chunks:[
74 | 'js/index.js',
75 | 'js/index.css',
76 | 'libs/react.js',
77 | ],
78 | templateContent: function(tpl) {
79 | // 生产环境不作处理
80 | if (!this.webpackOptions.watch) {
81 | return tpl;
82 | }
83 | // 开发环境先去掉外链react.js
84 | var regex = new RegExp("<\/script>", "ig");
85 | tpl = tpl.replace(regex, function(script, route) {
86 | if (!!~script.indexOf('react.js') || !!~script.indexOf('react-dom.js')) {
87 | return '';
88 | }
89 | return script;
90 | });
91 | return tpl;
92 | },
93 | htmlMinify: {
94 | removeComments: true,
95 | collapseWhitespace: true,
96 | }
97 | }),
98 | new WebpackAssetPipeline(),
99 | ],
100 | };
--------------------------------------------------------------------------------
/test/src/resource-md5-2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/src/resource-md5-2/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-md5-2/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-md5-2/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-md5-2/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 |
10 | var HtmlResWebpackPlugin = require('../../../index'),
11 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
12 | WebpackAssetPipeline = require('webpack-asset-pipeline');
13 |
14 | module.exports = {
15 | context: config.path.src,
16 | entry: {
17 | 'libs/react': [path.join(config.path.src, "/resource-md5-2/libs/react")],
18 | 'js/index': [path.join(config.path.src, "/resource-md5-2/index")],
19 | },
20 | output: {
21 | publicPath: config.defaultPath,
22 | path: path.join(config.path.dist + '/resource-md5-2/'),
23 | filename: "[name]" + config.chunkhash + ".js",
24 | chunkFilename: "chunk/[name]" + config.chunkhash + ".js",
25 | },
26 | module: {
27 | rules: [
28 | {
29 | test: /\.js?$/,
30 | loader: 'babel-loader',
31 | query: {
32 | cacheDirectory: false,
33 | presets: [
34 | 'es2015',
35 | ]
36 | },
37 | exclude: /node_modules/,
38 | },
39 | {
40 | test: /\.less$/,
41 | use: [
42 | MiniCssExtractPlugin.loader,
43 | {
44 | loader: 'css-loader',
45 | options: {
46 | localIdentName: '[name]-[local]-[hash:base64:5]',
47 | }
48 | },
49 | {
50 | loader: 'less-loader',
51 | }
52 | ],
53 | },
54 | {
55 | test: /\.html$/,
56 | loader: 'html-loader'
57 | },
58 | {
59 | test: /\.(jpe?g|png|gif|svg)$/i,
60 | use: [
61 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
62 | ],
63 | include: path.resolve(config.path.src)
64 | },
65 | ],
66 | },
67 | plugins: [
68 | new webpack.NoEmitOnErrorsPlugin(),
69 | new MiniCssExtractPlugin({filename: "css/[name]-[contenthash:6].css"}),
70 | new HtmlResWebpackPlugin({
71 | filename: "index.html",
72 | template: config.path.src + "/resource-md5-2/index.html",
73 | chunks:[
74 | 'libs/react.js',
75 | 'js/index.js',
76 | 'js/index.css',
77 | ],
78 | templateContent: function(tpl) {
79 | // 生产环境不作处理
80 | if (!this.webpackOptions.watch) {
81 | return tpl;
82 | }
83 | // 开发环境先去掉外链react.js
84 | var regex = new RegExp("<\/script>", "ig");
85 | tpl = tpl.replace(regex, function(script, route) {
86 | if (!!~script.indexOf('react.js') || !!~script.indexOf('react-dom.js')) {
87 | return '';
88 | }
89 | return script;
90 | });
91 | return tpl;
92 | },
93 | htmlMinify: null
94 | }),
95 | new WebpackAssetPipeline(),
96 | ],
97 | };
--------------------------------------------------------------------------------
/test/src/resource-md5-3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/src/resource-md5-3/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-md5-3/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-md5-3/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-md5-3/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 |
10 | var HtmlResWebpackPlugin = require('../../../index'),
11 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
12 | WebpackAssetPipeline = require('webpack-asset-pipeline');
13 |
14 | module.exports = {
15 | context: config.path.src,
16 | entry: {
17 | 'react': [path.join(config.path.src, "/resource-md5-3/libs/react")],
18 | 'index': [path.join(config.path.src, "/resource-md5-3/index")],
19 | },
20 | output: {
21 | publicPath: config.defaultPath,
22 | path: path.join(config.path.dist + '/resource-md5-3/'),
23 | filename: "js/[name]" + config.chunkhash + ".js",
24 | chunkFilename: "js/chunk/[name]" + config.chunkhash + ".js",
25 | },
26 | module: {
27 | rules: [
28 | {
29 | test: /\.js?$/,
30 | loader: 'babel-loader',
31 | query: {
32 | cacheDirectory: false,
33 | presets: [
34 | 'es2015',
35 | ]
36 | },
37 | exclude: /node_modules/,
38 | },
39 | {
40 | test: /\.less$/,
41 | use: [
42 | MiniCssExtractPlugin.loader,
43 | {
44 | loader: 'css-loader',
45 | options: {
46 | localIdentName: '[name]-[local]-[hash:base64:5]',
47 | }
48 | },
49 | {
50 | loader: 'less-loader',
51 | }
52 | ],
53 | },
54 | {
55 | test: /\.html$/,
56 | loader: 'html-loader'
57 | },
58 | {
59 | test: /\.(jpe?g|png|gif|svg)$/i,
60 | use: [
61 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
62 | ],
63 | include: path.resolve(config.path.src)
64 | },
65 | ],
66 | },
67 | plugins: [
68 | new webpack.NoEmitOnErrorsPlugin(),
69 | new MiniCssExtractPlugin({filename: "css/[name]-[contenthash:6].css"}),
70 | new HtmlResWebpackPlugin({
71 | mode: "html",
72 | filename: "index.html",
73 | template: config.path.src + "/resource-md5-3/index.html",
74 | htmlMinify: null
75 | }),
76 | new WebpackAssetPipeline(),
77 | ],
78 | };
--------------------------------------------------------------------------------
/test/src/resource-md5-4/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/test/src/resource-md5-4/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-md5-4/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-md5-4/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-md5-4/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 |
10 | var HtmlResWebpackPlugin = require('../../../index'),
11 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
12 | WebpackAssetPipeline = require('webpack-asset-pipeline');
13 |
14 | module.exports = {
15 | context: config.path.src,
16 | entry: {
17 | 'js/react': [path.join(config.path.src, "/resource-md5-4/libs/react")],
18 | 'js/index': [path.join(config.path.src, "/resource-md5-4/index")],
19 | },
20 | output: {
21 | publicPath: config.defaultPath,
22 | path: path.join(config.path.dist + '/resource-md5-4/'),
23 | filename: "cdn/[name]" + config.chunkhash + ".js",
24 | chunkFilename: "js/chunk/[name]" + config.chunkhash + ".js",
25 | },
26 | module: {
27 | rules: [
28 | {
29 | test: /\.js?$/,
30 | loader: 'babel-loader',
31 | query: {
32 | cacheDirectory: false,
33 | presets: [
34 | 'es2015',
35 | ]
36 | },
37 | exclude: /node_modules/,
38 | },
39 | {
40 | test: /\.less$/,
41 | use: [
42 | MiniCssExtractPlugin.loader,
43 | {
44 | loader: 'css-loader',
45 | options: {
46 | localIdentName: '[name]-[local]-[hash:base64:5]',
47 | }
48 | },
49 | {
50 | loader: 'less-loader',
51 | }
52 | ],
53 | },
54 | {
55 | test: /\.html$/,
56 | loader: 'html-loader'
57 | },
58 | {
59 | test: /\.(jpe?g|png|gif|svg)$/i,
60 | use: [
61 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
62 | ],
63 | include: path.resolve(config.path.src)
64 | },
65 | ],
66 | },
67 | plugins: [
68 | new webpack.NoEmitOnErrorsPlugin(),
69 | new MiniCssExtractPlugin({filename: "cdn/css/[name]-[contenthash:6].css"}),
70 | new HtmlResWebpackPlugin({
71 | mode: "html",
72 | entryLog: true,
73 | filename: "index.html",
74 | template: config.path.src + "/resource-md5-4/index.html",
75 | htmlMinify: null
76 | }),
77 | new WebpackAssetPipeline(),
78 | ],
79 | optimization: {
80 | minimize: true
81 | }
82 | };
--------------------------------------------------------------------------------
/test/src/resource-md5-5/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/test/src/resource-md5-5/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-md5-5/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-md5-5/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-md5-5/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 |
10 | var HtmlResWebpackPlugin = require('../../../index'),
11 | MiniCssExtractPlugin = require('mini-css-extract-plugin'),
12 | WebpackAssetPipeline = require('webpack-asset-pipeline');
13 |
14 | module.exports = {
15 | context: config.path.src,
16 | entry: {
17 | 'js/react': [path.join(config.path.src, "/resource-md5-5/libs/react")],
18 | 'js/index': [path.join(config.path.src, "/resource-md5-5/index")],
19 | },
20 | output: {
21 | publicPath: config.defaultPath,
22 | path: path.join(config.path.dist + '/resource-md5-5/'),
23 | filename: "cdn/[name]" + config.chunkhash + ".js",
24 | chunkFilename: "js/chunk/[name]" + config.chunkhash + ".js",
25 | },
26 | module: {
27 | rules: [
28 | {
29 | test: /\.js?$/,
30 | loader: 'babel-loader',
31 | query: {
32 | cacheDirectory: false,
33 | presets: [
34 | 'es2015',
35 | ]
36 | },
37 | exclude: /node_modules/,
38 | },
39 | {
40 | test: /\.less$/,
41 | use: [
42 | MiniCssExtractPlugin.loader,
43 | {
44 | loader: 'css-loader',
45 | options: {
46 | localIdentName: '[name]-[local]-[hash:base64:5]',
47 | }
48 | },
49 | {
50 | loader: 'less-loader',
51 | }
52 | ],
53 | },
54 | {
55 | test: /\.html$/,
56 | loader: 'html-loader'
57 | },
58 | {
59 | test: /\.(jpe?g|png|gif|svg)$/i,
60 | use: [
61 | "url-loader?limit=1000&name=img/[name]" + config.hash + ".[ext]",
62 | ],
63 | include: path.resolve(config.path.src)
64 | },
65 | ],
66 | },
67 | plugins: [
68 | new webpack.NoEmitOnErrorsPlugin(),
69 | new MiniCssExtractPlugin({filename: "cdn/css/[name]-[contenthash:6].css"}),
70 | new HtmlResWebpackPlugin({
71 | mode: "html",
72 | entryLog: true,
73 | filename: "index.html",
74 | template: config.path.src + "/resource-md5-5/index.html",
75 | htmlMinify: null
76 | }),
77 | new WebpackAssetPipeline(),
78 | ],
79 | optimization: {
80 | minimize: true
81 | }
82 | };
--------------------------------------------------------------------------------
/test/src/resource-production-1/detail.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/src/resource-production-1/detail.js:
--------------------------------------------------------------------------------
1 | require('./detail.less');
--------------------------------------------------------------------------------
/test/src/resource-production-1/detail.less:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-production-1/detail.less
--------------------------------------------------------------------------------
/test/src/resource-production-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/src/resource-production-1/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-production-1/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-production-1/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-production-1/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | 'libs/react': [path.join(config.path.src, "/resource-production-1/libs/react")],
16 | 'index': [path.join(config.path.src, "/resource-production-1/index")],
17 | 'detail': [path.join(config.path.src, "/resource-production-1/detail")],
18 | },
19 | output: {
20 | publicPath: config.defaultPath,
21 | path: path.join(config.path.dist + '/resource-production-1/'),
22 | filename: "js/[name].js",
23 | chunkFilename: "chunk/[name].js",
24 | },
25 | module: {
26 | rules: [
27 | {
28 | test: /\.js?$/,
29 | loader: 'babel-loader',
30 | query: {
31 | cacheDirectory: false,
32 | presets: [
33 | 'es2015',
34 | ]
35 | },
36 | exclude: /node_modules/,
37 | },
38 | {
39 | test: /\.less$/,
40 | use: [
41 | MiniCssExtractPlugin.loader,
42 | {
43 | loader: 'css-loader',
44 | options: {
45 | localIdentName: '[name]-[local]-[hash:base64:5]',
46 | }
47 | },
48 | {
49 | loader: 'less-loader',
50 | }
51 | ],
52 | },
53 | {
54 | test: /\.html$/,
55 | loader: 'html-loader'
56 | },
57 | {
58 | test: /\.(jpe?g|png|gif|svg)$/i,
59 | use: [
60 | "url-loader?limit=1&name=img/[name].[ext]",
61 | ],
62 | include: path.resolve(config.path.src)
63 | },
64 | ],
65 | },
66 | plugins: [
67 | new webpack.NoEmitOnErrorsPlugin(),
68 | new MiniCssExtractPlugin({
69 | filename: "css/[name].css",
70 | publicPath: "//localhost:1111/",
71 | }),
72 | new HtmlResWebpackPlugin({
73 | env: "development",
74 | mode: 'html',
75 | filename: "html/entry.html",
76 | template: config.path.src + "/resource-production-1/index.html",
77 | cssPublicPath: "//localhost:1111/",
78 | removeUnMatchedAssets: true,
79 | htmlMinify: null
80 | }),
81 | new HtmlResWebpackPlugin({
82 | env: "development",
83 | mode: 'html',
84 | filename: "html/detail.html",
85 | template: config.path.src + "/resource-production-1/detail.html",
86 | cssPublicPath: "//localhost:1111/",
87 | removeUnMatchedAssets: true,
88 | htmlMinify: null
89 | })
90 | ],
91 | watch: true,
92 | };
--------------------------------------------------------------------------------
/test/src/resource-production/detail.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/src/resource-production/detail.js:
--------------------------------------------------------------------------------
1 | require('./detail.less');
--------------------------------------------------------------------------------
/test/src/resource-production/detail.less:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-production/detail.less
--------------------------------------------------------------------------------
/test/src/resource-production/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/src/resource-production/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-production/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-production/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-production/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | 'libs/react': [path.join(config.path.src, "/resource-production/libs/react")],
16 | 'index': [path.join(config.path.src, "/resource-production/index")],
17 | 'detail': [path.join(config.path.src, "/resource-production/detail")],
18 | },
19 | output: {
20 | publicPath: config.defaultPath,
21 | path: path.join(config.path.dist + '/resource-production/'),
22 | filename: "js/[name].js",
23 | chunkFilename: "chunk/[name].js",
24 | },
25 | module: {
26 | rules: [
27 | {
28 | test: /\.js?$/,
29 | loader: 'babel-loader',
30 | query: {
31 | cacheDirectory: false,
32 | presets: [
33 | 'es2015',
34 | ]
35 | },
36 | exclude: /node_modules/,
37 | },
38 | {
39 | test: /\.less$/,
40 | use: [
41 | MiniCssExtractPlugin.loader,
42 | {
43 | loader: 'css-loader',
44 | options: {
45 | localIdentName: '[name]-[local]-[hash:base64:5]',
46 | }
47 | },
48 | {
49 | loader: 'less-loader',
50 | }
51 | ],
52 | },
53 | {
54 | test: /\.html$/,
55 | loader: 'html-loader'
56 | },
57 | {
58 | test: /\.(jpe?g|png|gif|svg)$/i,
59 | use: [
60 | "url-loader?limit=1&name=img/[name].[ext]",
61 | ],
62 | include: path.resolve(config.path.src)
63 | },
64 | ],
65 | },
66 | plugins: [
67 | new webpack.NoEmitOnErrorsPlugin(),
68 | new MiniCssExtractPlugin({
69 | filename: "css/[name].css",
70 | publicPath: "//localhost:1111/",
71 | }),
72 | new HtmlResWebpackPlugin({
73 | env: "production",
74 | mode: 'html',
75 | filename: "html/entry.html",
76 | template: config.path.src + "/resource-production/index.html",
77 | cssPublicPath: "//localhost:1111/",
78 | removeUnMatchedAssets: true,
79 | htmlMinify: null
80 | }),
81 | new HtmlResWebpackPlugin({
82 | env: "production",
83 | mode: 'html',
84 | filename: "html/detail.html",
85 | template: config.path.src + "/resource-production/detail.html",
86 | cssPublicPath: "//localhost:1111/",
87 | removeUnMatchedAssets: true,
88 | htmlMinify: null
89 | })
90 | ],
91 | watch: true,
92 | };
--------------------------------------------------------------------------------
/test/src/resource-query-1/detail.js:
--------------------------------------------------------------------------------
1 | require('./detail.less');
--------------------------------------------------------------------------------
/test/src/resource-query-1/detail.less:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-query-1/detail.less
--------------------------------------------------------------------------------
/test/src/resource-query-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/src/resource-query-1/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-query-1/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-query-1/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-query-1/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config');
7 |
8 | var HtmlResWebpackPlugin = require('../../../index'),
9 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
10 |
11 | module.exports = {
12 | context: config.path.src,
13 | entry: {
14 | 'libs/react': [path.join(config.path.src, "/resource-query-1/libs/react")],
15 | 'index': [path.join(config.path.src, "/resource-query-1/index")],
16 | 'detail': [path.join(config.path.src, "/resource-query-1/detail")],
17 | },
18 | output: {
19 | publicPath: config.defaultPath,
20 | path: path.join(config.path.dist + '/resource-query-1/'),
21 | filename: "js/[name].js",
22 | chunkFilename: "chunk/[name].js",
23 | },
24 | module: {
25 | rules: [
26 | {
27 | test: /\.js?$/,
28 | loader: 'babel-loader',
29 | query: {
30 | cacheDirectory: false,
31 | presets: [
32 | 'es2015',
33 | ]
34 | },
35 | exclude: /node_modules/,
36 | },
37 | {
38 | test: /\.less$/,
39 | use: [
40 | MiniCssExtractPlugin.loader,
41 | {
42 | loader: 'css-loader',
43 | options: {
44 | localIdentName: '[name]-[local]-[hash:base64:5]',
45 | }
46 | },
47 | {
48 | loader: 'less-loader',
49 | }
50 | ],
51 | },
52 | {
53 | test: /\.html$/,
54 | loader: 'html-loader'
55 | },
56 | {
57 | test: /\.(jpe?g|png|gif|svg)$/i,
58 | use: [
59 | "url-loader?limit=1&name=img/[name].[ext]",
60 | ],
61 | include: path.resolve(config.path.src)
62 | },
63 | ],
64 | },
65 | plugins: [
66 | new webpack.NoEmitOnErrorsPlugin(),
67 | new MiniCssExtractPlugin({
68 | filename: "css/[name].css",
69 | publicPath: "//localhost:1111/",
70 | }),
71 | new HtmlResWebpackPlugin({
72 | mode: 'html',
73 | filename: "html/entry.html",
74 | template: config.path.src + "/resource-query-1/index.html",
75 | cssPublicPath: "//localhost:1111/",
76 | removeUnMatchedAssets: true,
77 | htmlMinify: null
78 | })
79 | ],
80 | watch: true,
81 | };
--------------------------------------------------------------------------------
/test/src/resource-remove/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Tencent QQ
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/test/src/resource-remove/index.js:
--------------------------------------------------------------------------------
1 |
2 | require('./index.less');
3 |
4 | require('./index.png');
5 |
6 | require('./index.json');
7 |
8 | var a = "hello world!";
--------------------------------------------------------------------------------
/test/src/resource-remove/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "a": 1,
3 | "b": 2
4 | }
--------------------------------------------------------------------------------
/test/src/resource-remove/index.less:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/test/src/resource-remove/index.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-remove/index.png
--------------------------------------------------------------------------------
/test/src/resource-remove/libs/react.js:
--------------------------------------------------------------------------------
1 | var react = {
2 | reactDom: function() {
3 |
4 | }
5 | };
--------------------------------------------------------------------------------
/test/src/resource-remove/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcxfs1991/html-res-webpack-plugin/b26082a54b095045fd0af9e504f468bf62a3459f/test/src/resource-remove/logo.png
--------------------------------------------------------------------------------
/test/src/resource-remove/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 |
5 | var webpack = require('webpack'),
6 | config = require('../../config/config'),
7 | nodeModulesPath = path.resolve('../node_modules');
8 |
9 | var HtmlResWebpackPlugin = require('../../../index'),
10 | MiniCssExtractPlugin = require('mini-css-extract-plugin');
11 |
12 | module.exports = {
13 | context: config.path.src,
14 | entry: {
15 | 'libs/react': [path.join(config.path.src, "/resource-remove/libs/react")],
16 | 'index': [path.join(config.path.src, "/resource-remove/index")],
17 | },
18 | output: {
19 | publicPath: config.defaultPath,
20 | path: path.join(config.path.dist + '/resource-remove/'),
21 | filename: "js/[name].js",
22 | chunkFilename: "chunk/[name].js",
23 | },
24 | module: {
25 | rules: [
26 | {
27 | test: /\.js?$/,
28 | loader: 'babel-loader',
29 | query: {
30 | cacheDirectory: false,
31 | presets: [
32 | 'es2015',
33 | ]
34 | },
35 | exclude: /node_modules/,
36 | },
37 | {
38 | test: /\.less$/,
39 | use: [
40 | MiniCssExtractPlugin.loader,
41 | {
42 | loader: 'css-loader',
43 | options: {
44 | localIdentName: '[name]-[local]-[hash:base64:5]',
45 | }
46 | },
47 | {
48 | loader: 'less-loader',
49 | }
50 | ],
51 | },
52 | {
53 | test: /\.html$/,
54 | loader: 'html-loader'
55 | },
56 | {
57 | test: /\.(jpe?g|png|gif|svg)$/i,
58 | use: [
59 | "url-loader?limit=1&name=img/[name].[ext]",
60 | ],
61 | include: path.resolve(config.path.src)
62 | },
63 | ],
64 | },
65 | plugins: [
66 | new webpack.NoEmitOnErrorsPlugin(),
67 | new MiniCssExtractPlugin({
68 | filename: "css/[name].css",
69 | publicPath: "//localhost:1111/",
70 | }),
71 | new HtmlResWebpackPlugin({
72 | env: 'production',
73 | mode: 'html',
74 | filename: "html/entry.html",
75 | template: config.path.src + "/resource-remove/index.html",
76 | cssPublicPath: "//localhost:1111/",
77 | removeUnMatchedAssets: true,
78 | htmlMinify: null
79 | })
80 | ],
81 | watch: true,
82 | };
--------------------------------------------------------------------------------