rollup.config.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Rollup plugins
  2. import babel from "rollup-plugin-babel";
  3. import resolve from "rollup-plugin-node-resolve";
  4. import commonjs from "rollup-plugin-commonjs";
  5. // import replace from "rollup-plugin-replace";
  6. import { terser } from "rollup-plugin-terser"; // Rollup plugin to minify generated es bundle.
  7. import { string } from "rollup-plugin-string";
  8. // 这个 rollup-plugin-commonjs 插件就是用来将 CommonJS 转换成 ES2015 模块的。
  9. import { uglify } from "rollup-plugin-uglify"; // 这个东西不支持ES6的构建的时候 得target是ES5
  10. import postcss from "rollup-plugin-postcss";
  11. // import nested from "postcss-nested";
  12. import cssnext from "postcss-cssnext";
  13. // import template from "rollup-plugin-templatejs";
  14. import sass from "rollup-plugin-sass";
  15. // import expression from "@templatejs/runtime";
  16. export default {
  17. plugins: [
  18. postcss({
  19. plugins: [cssnext()],
  20. extensions: [".scss"],
  21. }),
  22. sass({
  23. insert: true,
  24. }),
  25. resolve({
  26. jsnext: true,
  27. main: true,
  28. browser: true,
  29. }),
  30. commonjs(),
  31. babel({
  32. exclude: "node_modules/**",
  33. }),
  34. string({
  35. // Required to be specified
  36. include: "**/*.tmpl",
  37. // Undefined by default
  38. exclude: ["**/index.html"]
  39. })
  40. // template({
  41. // sTag: "<#",
  42. // eTag: "#>",
  43. // expression: "requrie('@templatejs/runtime')", // 获取template的表达式,如 `window.template`
  44. // sandbox: false, // 沙箱模式
  45. // include: ["**/*.tmpl"], // 默认值
  46. // exclude: "node_modules/**", // 默认值
  47. // }),
  48. // replace({
  49. // ENV: JSON.stringify(process.env.NODE_ENV || "development"),
  50. // }),
  51. // terser(),
  52. // uglify(),
  53. ],
  54. input: "./src/main.js",
  55. output: [
  56. {
  57. file: "../../build/plugins/plugins-popup-tksj.js",
  58. format: "umd", //"amd", "cjs", "system", "esm", "iife" or "umd".
  59. name: "main",
  60. },
  61. ],
  62. };